Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
6a5867e
Fix first-run harvest: list tracked files, order-safe chunk joins, ch…
northdpole Oct 5, 2026
4d375d5
Add scheduled OIE runs: OWASP (10 min) and CRE expansion (daily)
northdpole Oct 5, 2026
643e6e1
Report the agent index target in scheduled agent_sync
northdpole Oct 5, 2026
eb95ff1
Chain oie_run Alembic revision after source_channel.
northdpole Oct 14, 2026
0994bed
Add signed-in admin showcase and Brevity bot skill.
northdpole Oct 6, 2026
080ffa8
Complete remaining admin showcase plan items.
northdpole Oct 6, 2026
c9f19de
Guard admin fetches on unmount and type the config catalog.
northdpole Oct 6, 2026
c102785
Fix mapping edit fields and lock HTTP OIE to dry-run.
northdpole Oct 6, 2026
dc8cb26
Drop unused ingest kwargs after HTTP OIE lock.
northdpole Oct 6, 2026
e2815e9
Run HTTP OIE start in a dry-run child process.
northdpole Oct 6, 2026
db09073
Add plan-required admin tests for disabled agent, pipeline errors, an…
northdpole Oct 6, 2026
a56f660
Isolate HTTP OIE on sqlite and surface failed starts.
northdpole Oct 6, 2026
1a6488a
Gate /admin on capabilities.admin and surface delete errors.
northdpole Oct 6, 2026
0690ed6
Treat failed changeset fetches as errors in admin review.
northdpole Oct 6, 2026
e8d7675
Drop restated admin-panel comments after Brevity review.
northdpole Oct 6, 2026
20f5733
Shorten admin login copy and drop restated MyOpenCRE blurb.
northdpole Oct 6, 2026
6859e05
Handle empty Impact keys with logs and JSON errors.
northdpole Oct 6, 2026
03612c2
Show impact warnings in Admin and format helpers.
northdpole Oct 6, 2026
5d77d3f
Keep stacked Nest agent env; agent DB is Postgres.
northdpole Oct 6, 2026
51c243c
Treat OWASP_AGENT_DB as Postgres only.
northdpole Oct 6, 2026
5a05310
Redact passwords in OWASP_AGENT_DB admin display.
northdpole Oct 6, 2026
5f3a6f3
Harden admin targets, ingest, and mapping errors.
northdpole Oct 6, 2026
40e16f5
Add admin repos.yaml editor, org expand, and one-off ingest.
northdpole Oct 6, 2026
84e9839
Harden repos.yaml org expand and yaml size limits.
northdpole Oct 6, 2026
3b58d49
Rebuild frontend bundle for repos.yaml admin editor.
northdpole Oct 6, 2026
c1bf1b5
Raise repos.yaml admin cap to 4MiB for org expands.
northdpole Oct 6, 2026
dce904e
Decouple repos.yaml config from GitHub org expansion.
northdpole Oct 6, 2026
c8f3298
Treat the OWASP agent as a built-in ingest resource.
northdpole Oct 6, 2026
2a4015d
Reject inaccessible GitHub sources at config time.
northdpole Oct 6, 2026
a477189
Redesign admin IA: dashboard, config, pipeline, graph.
northdpole Oct 6, 2026
bccae60
Rebuild frontend bundle for the admin IA redesign.
northdpole Oct 6, 2026
87824bc
Persist Add org on save and mark apply_failed on the strip.
northdpole Oct 6, 2026
2f0da3f
Drop OWASP_AGENT_DB; agent uses the main app Postgres.
northdpole Oct 6, 2026
9ab2499
Fix OIE child import path; agent index uses the main DB.
northdpole Oct 6, 2026
555c4e7
Run admin OIE on Docker Postgres; drop sqlite:// child cache.
northdpole Oct 6, 2026
61bfcf9
Align Flask/agent DB env order; always pin psycopg2 dialect.
northdpole Oct 6, 2026
1422dee
Make admin ingest run OIE end-to-end without false Module A errors.
northdpole Oct 6, 2026
0d372bc
Skip invalid harvest docs; surface agent last_sync from meta_entity.
northdpole Oct 6, 2026
3322ed0
Restore degraded stop contract; tighten admin ingest defaults.
northdpole Oct 6, 2026
1e5b4e5
Fix Graph management Accept/errors for empty OIE import runs.
northdpole Oct 6, 2026
f3ec363
Surface OIE skip reasons, flags, and graph path in pipeline logs.
northdpole Oct 6, 2026
3d820cb
Auto-pull CRE graph in admin-local when Postgres is empty.
northdpole Oct 6, 2026
15a4fa1
Wire Postgres admin bootstrap into make install and make dev.
northdpole Oct 6, 2026
f814150
Wire golden-set harvest and OWASP agent sync into Admin Config.
northdpole Oct 6, 2026
45eb358
Add Mac handover for admin/OIE/agent E2E validation.
northdpole Oct 6, 2026
afb0948
Chain admin panel tables migration after oie_run
northdpole Oct 6, 2026
aabb90b
Black-format admin_imports_api_test for CI
northdpole Oct 6, 2026
7871306
Run admin OIE ingest through Modules B and C by default.
northdpole Oct 7, 2026
bfcb1e4
Paint Module C auto-filed graph edges and nodes in the explorer.
northdpole Oct 7, 2026
0f22476
Add Module C.1 graph filing to the OIE A→B→C pipeline.
northdpole Oct 7, 2026
7b9b007
Default Module C.1 auto-filing off behind an admin Config toggle.
northdpole Oct 7, 2026
18ed280
Restore clarify followup test dropped in admin rebase.
northdpole Oct 12, 2026
5308183
style: format files flagged by CI (black, prettier)
northdpole Oct 22, 2026
9262fde
test: fix stale admin config assertion, env leaks between tests, and …
northdpole Oct 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .cursor/skills/brevity-bot/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
name: brevity-bot
description: >-
Review a diff like a long-tenured greybeard coworker: shorten AI blurbs,
simplify code, keep correctness/security/Bugbot fixes. Use after Bugbot and
Security reviews, or when asked for /review-brevity.
---

# Brevity bot

You are the ponytailed, greybearded, Linux-using god of coworker who has been
with the company since the beginning. You can shorten or simplify any codebase.
Your job is to dramatically increase readability and quality and shorten AI
blurbs while preserving correctness, quality, and security.

You simplify code **without dropping the fixes** from Bugbot or Security
review. If a check, error path, redaction, auth gate, or test exists because
those reviews required it, keep it. Prefer a shorter form of the same fix.

## Diff contract (same as Bugbot)

The parent gives:

```text
Full Repository Path: <absolute path>
Diff: <branch changes | uncommitted changes>
```

Review that diff only. Do not invent drive-by refactors outside it.

## What to cut

- Restated comments, essay docstrings, "as an AI" padding, changelog comments
- Needless wrappers, duplicate branches, unused helpers, speculative abstraction
- Tests that only restate the same assertion five ways

## What to keep

- Auth, allowlists, redaction, abort codes, CSRF/login gates
- Bugbot/Security fixes (narrower code is fine; weaker checks are not)
- Names and structure that match this repo (`application/tests/`, Makefile)

## Output

Either:

1. **Patches** — file path, short why, and the smaller replacement, or
2. **`NO_COMMENTS`** — nothing left to shorten without harming clarity, tests,
or security.

End with exactly one of:

- `VERDICT: NO_COMMENTS`
- `VERDICT: COMMENTS` (and the patch list)

Do not praise the diff. Do not recap the plan.
40 changes: 40 additions & 0 deletions .cursor/skills/brevity-bot/examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Brevity bot fixtures

## AI blurb → short

Before:

```python
def is_enabled() -> bool:
"""Return True if the feature flag is enabled.

This function checks the environment variable and compares it against
a set of truthy values so that operators can enable the feature.
"""
value = os.getenv("FLAG", "")
normalized = value.strip().lower()
if normalized in {"1", "true", "yes"}:
return True
return False
```

After:

```python
def is_enabled() -> bool:
return os.getenv("FLAG", "").strip().lower() in {"1", "true", "yes"}
```

## Do not drop a security fix

Security required redacting secrets. Illegal brevity (drops the fix):

```python
return {"GEMINI_API_KEY": os.environ.get("GEMINI_API_KEY")}
```

Legal brevity (keeps redaction):

```python
return {"GEMINI_API_KEY": "***"} if os.environ.get("GEMINI_API_KEY") else {}
```
24 changes: 24 additions & 0 deletions .cursor/skills/review-brevity/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: review-brevity
description: Launch Brevity bot on the current diff after Bugbot and Security.
---

# Review Brevity

When asked to run `/review-brevity` or Brevity bot:

Launch **three** independent `generalPurpose` subagents (`run_in_background: false`)
with the contents of `.cursor/skills/brevity-bot/SKILL.md` as instructions.

Prompt each with:

```text
Full Repository Path: <absolute repository path>
Diff: branch changes
```

Default to `branch changes`. Use `uncommitted changes` only if asked.

Collect the three `VERDICT:` lines. Majority `NO_COMMENTS` (2 of 3) is clean.
If majority is `COMMENTS`, apply agreed simplifications that do **not** revert
Bugbot or Security fixes, then re-run.
15 changes: 11 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
# Never commit your real `.env` file to version control.
# ------------------------------------------------------------------------------
# Database
# Local Docker (make docker-postgres / make admin-local):
# postgresql://cre:password@127.0.0.1:5432/cre
# `make admin-local` starts that container when the URL is unreachable and
# never falls back to SQLite for the admin showcase.

DEV_DATABASE_URL=postgresql://user:password@localhost:5432/opencre

Expand Down Expand Up @@ -42,14 +46,17 @@ CRE_ENABLE_MYOPENCRE=false
CRE_ENABLE_LOGIN=false

# Experimental OIE OWASP metadata agent (chat + MCP only — never CRE graph UI).
# Off by default. When enabled, community/meta questions are answered from
# the local owasp_agent index instead of CRE RAG. Concepts/tags stay in
# OWASP_AGENT_DB and are reachable only from /completion and MCP owasp_meta_* tools.
# Off by default. Uses the main app Postgres (DEV_DATABASE_URL / DATABASE_URL)
# for the agent index + pgvector. Reachable from /completion and MCP owasp_meta_* tools.
OWASP_AGENT_ENABLED=false

# Module C.1 graph filing (Automatically linked to). Off by default — leave Module C
# decisions in decision_queue for review; set true to auto-add high-confidence links.
OIE_GRAPH_FILING_ENABLED=false

# Nest REST API key (https://nest.owasp.org — create via GraphQL while logged in)
NEST_API_KEY=
NEST_API_BASE=https://nest.owasp.org/api/v0
OWASP_AGENT_DB=tmp/owasp_agent.sqlite
# Set to 1 to crawl all www-chapter / www-project repos during sync (slow).
OWASP_AGENT_CRAWL_REPOS=0

Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ v/
.cursor/*
!.cursor/rules/
!.cursor/rules/**
!.cursor/skills/
!.cursor/skills/**
.claude/

### Frontend
Expand All @@ -67,6 +69,7 @@ standards_cache.sqlite
### Docs
*.md
!AGENTS.md
!.cursor/skills/**/*.md
!docs/faq.md
!docs/api/mcp.md
!docs/Mid_eval_blog_gsoc2026/module_B_mideval_blog.md
Expand Down Expand Up @@ -94,6 +97,8 @@ neo4j/
.mypy_cache
tmp/

import_telemetry.json

### CREs dir
cres/*
### Local project management tooling
Expand Down
42 changes: 37 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.ONESHELL:

.PHONY: run test covers install-deps dev docker lint frontend clean all e2e e2e-db owasp-agent-sync owasp-agent-merge-concepts owasp-agent-synth-eval
.PHONY: run test covers install-deps dev dev-flask docker lint frontend clean all e2e e2e-db admin-local owasp-agent-sync owasp-agent-merge-concepts owasp-agent-synth-eval

prod-run:
gunicorn cre:app --log-file=-
Expand Down Expand Up @@ -74,11 +74,19 @@ start-worker:
. ./venv/bin/activate && FLASK_APP=`pwd`/cre.py python cre.py --start_worker

upstream-sync:
. ./venv/bin/activate && python cre.py --upstream_sync
. ./venv/bin/activate &&\
python cre.py --upstream_sync --cache_file "$(or $(DEV_DATABASE_URL),$(CRE_CACHE_FILE),$(CURDIR)/standards_cache.sqlite)"

PORT?=5000

dev-flask:
# Local app against Docker Postgres: migrate, upstream-sync if cre/node empty, Flask.
# Same entrypoint as admin showcase / OIE local (no SQLite). macOS AirPlay often
# holds :5000 — use PORT=5001 make dev if bind fails.
dev dev-flask admin-local:
bash ./scripts/run_admin_local.sh --port $(PORT) $(ADMIN_LOCAL_ARGS)

# Bare Flask without Postgres bootstrap (legacy / CI helpers). Prefer `make dev`.
dev-flask-sqlite:
. ./venv/bin/activate && INSECURE_REQUESTS=1 FLASK_APP=`pwd`/cre.py FLASK_CONFIG=development flask run --port $(PORT)

dev-flask-docker:
Expand Down Expand Up @@ -136,7 +144,14 @@ install-deps-typescript:
install-deps: install-deps-python install-deps-typescript

install-python:
virtualenv -p python3 venv
@if [ ! -d "./venv" ]; then \
if command -v virtualenv >/dev/null 2>&1; then \
virtualenv -p python3 venv; \
else \
echo "virtualenv not on PATH — using python3 -m venv"; \
python3 -m venv venv; \
fi; \
fi
. ./venv/bin/activate &&\
make install-deps-python &&\
playwright install # Python embeddings/scraping (prompt_client); NOT frontend e2e — keep when migrating to Cypress
Expand All @@ -148,7 +163,9 @@ install-python:
# `make install`. Rebuild with `make frontend` when you change the UI.
install-typescript: install-deps-typescript

install: install-typescript install-python migrate-upgrade
# Deps + Docker Postgres schema + CRE upstream graph when empty (see run_admin_local.sh).
install: install-typescript install-python
bash ./scripts/run_admin_local.sh --migrate-only $(ADMIN_LOCAL_ARGS)

docker-dev:
docker build -f Dockerfile-dev -t opencre-dev:$(shell git rev-parse HEAD) .
Expand Down Expand Up @@ -273,6 +290,21 @@ monitor-chatbot-health-prod:
--base-url "https://opencre.org" \
--output-json "$(CURDIR)/tmp/prod-chatbot-health.json"

# Scheduled OIE jobs (Postgres only). Cron `make oie-tick` every 10 minutes: each
# job runs once per slot (owasp every 10 min, cre_expansion daily) and is a no-op
# otherwise. Overrides: OIE_JOB=owasp|cre_expansion|all, OIE_FORCE=1, OIE_DRY_RUN=1.
oie-tick:
@[ -d "./.venv" ] && . ./.venv/bin/activate || ([ -d "./venv" ] && . ./venv/bin/activate); \
export CRE_CACHE_FILE="$${CRE_CACHE_FILE:-postgresql://cre:password@127.0.0.1:5432/cre}"; \
python cre.py --cache_file "$$CRE_CACHE_FILE" --run_scheduled "$${OIE_JOB:-all}" \
$${OIE_FORCE:+--scheduled_force} $${OIE_DRY_RUN:+--scheduled_dry_run}

monitor-oie-health:
@[ -d "./.venv" ] && . ./.venv/bin/activate || ([ -d "./venv" ] && . ./venv/bin/activate); \
export CRE_CACHE_FILE="$${CRE_CACHE_FILE:-postgresql://cre:password@127.0.0.1:5432/cre}"; \
export PYTHONPATH="$(CURDIR)"; \
python scripts/monitor_oie_health.py --output-json "$(CURDIR)/tmp/oie-health.json"

verify-ga-parity-local:
@[ -d "./.venv" ] && . ./.venv/bin/activate || ([ -d "./venv" ] && . ./venv/bin/activate); \
export CRE_CACHE_FILE="$${CRE_CACHE_FILE:-postgresql://cre:password@127.0.0.1:5432/cre}"; \
Expand Down
21 changes: 5 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,44 +49,33 @@ If you want to develop on OpenCRE or docker is not available in your environment
### Command Line

To run outside of Docker you need to install OpenCRE.
To install this application you need Python 3.11.9, Node.js, Yarn Classic (the repository uses a Yarn v1 lockfile), and `virtualenv`. The Python version is pinned in `.python-version`; the repository does not currently pin a Node.js version.
To install this application you need Python 3.11.9, Node.js, Yarn Classic (the repository uses a Yarn v1 lockfile), and Docker (local Postgres). `virtualenv` is optional — `make install-python` falls back to `python3 -m venv`. The Python version is pinned in `.python-version`; the repository does not currently pin a Node.js version.

Clone the repository:

```bash
git clone https://github.com/OWASP/OpenCRE
```

`make install` creates and uses the project virtual environment. Do not create a second environment with `python3 -m venv`; install the prerequisites above, then let the Makefile manage `venv`.

Install dependencies:
`make install` creates the project `venv` (if missing), installs deps, starts Docker Postgres when needed, migrates, and pulls the CRE graph from opencre.org when the local DB is empty.

```bash
make install
make dev # same as make dev-flask / make admin-local
```

`make install` creates the local schema as part of installation. Download the latest CRE graph from upstream with:

```bash
make upstream-sync
```
Then open http://127.0.0.1:5000/admin and http://127.0.0.1:5000/explorer. If port 5000 is busy (common on macOS with AirPlay Receiver), use `PORT=5001 make dev`. To reuse an existing DB without re-pulling the CRE graph: `SKIP_UPSTREAM_SYNC=1 PORT=5001 make dev`.

For contributors, this is the supported local data bootstrap path. You do
**not** need access to the internal OpenCRE Google Sheet to work on the
project.
project. From **Admin → Config**, use **Run golden-set harvest** and **Sync OWASP agent** (progress under Pipeline), or `make owasp-agent-sync` from the CLI.

You can precompute local gap-analysis cache after imports with:

```bash
make backfill-gap-analysis
```

To run CRE locally then you can do:

```bash
make dev-flask
```

To run the CLI application, you can run:

```bash
Expand Down
47 changes: 47 additions & 0 deletions application/cmd/cre_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,39 @@ def backfill_gap_analysis_only(
logger.info("GA backfill complete: final_missing_pairs=%s", final_missing)


def run_scheduled_cli(args: argparse.Namespace, collection: db.Node_collection) -> int:
"""``--run_scheduled``: run the selected OIE job(s); return a process exit code.

Postgres only -- the advisory-lock lease and the run table assume it, and the
default ``standards_cache.sqlite`` must not silently become the scheduler's
database. Exit 1 when a job errored, 2 for a non-Postgres database.
"""
import json

from application.utils.oie_scheduler.runner import run_due_jobs

dialect = collection.session.get_bind().dialect.name
if dialect != "postgresql":
logger.error(
"--run_scheduled is Postgres-only (got %s); point --cache_file at "
"a postgresql:// URL (make docker-postgres for a local one)",
dialect,
)
return 2
selected = args.run_scheduled
force = bool(getattr(args, "scheduled_force", False))
outcomes = run_due_jobs(
collection,
cache_file=args.cache_file,
jobs=None if selected == "all" else [selected],
force=force,
dry_run=bool(getattr(args, "scheduled_dry_run", False)),
trigger="manual" if force else "scheduled",
)
print(json.dumps([o.to_dict() for o in outcomes], indent=2))
return 1 if any(o.failed for o in outcomes) else 0


def run(args: argparse.Namespace) -> None: # pragma: no cover
script_path = os.path.dirname(os.path.realpath(__file__))
os.path.join(script_path, "../cres")
Expand All @@ -892,6 +925,14 @@ def run(args: argparse.Namespace) -> None: # pragma: no cover
logger.info("Exported %s rows to %s", rows, csv_out)
return

if getattr(args, "run_scheduled", ""):
import sys

code = run_scheduled_cli(args, db_connect(args.cache_file))
if code:
sys.exit(code)
return

if getattr(args, "run_harvester", False):
import sys

Expand All @@ -905,6 +946,12 @@ def run(args: argparse.Namespace) -> None: # pragma: no cover
args.run_id.strip(),
repos_yaml=repos_yaml,
dry_run=getattr(args, "harvester_dry_run", False),
kinds=[
k.strip()
for k in (getattr(args, "harvester_kinds", "") or "").split(",")
if k.strip()
]
or None,
)
print(summary.to_json())
if summary.status == "degraded":
Expand Down
Loading
Loading