Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
f4c314d
feat(librarian): Module C retrieval upgrades (stack base for #1088)
northdpole Sep 29, 2026
8368601
Address review feedback on OIE librarian base.
northdpole Oct 5, 2026
70af687
feat(harvester): requirement extract and GitHub URL ingest
northdpole Sep 29, 2026
583e987
feat(oie): B2 eval harness and CRE neighborhood scorer
northdpole Sep 29, 2026
7fe303e
feat(librarian): LLM SafetyGuard for C.4 adversarial / update flags
northdpole Oct 7, 2026
62d0c4b
Address review feedback on harvester and GitHub URL ingest.
northdpole Oct 5, 2026
25f07e1
Address review feedback on B2 harness scripts.
northdpole Oct 5, 2026
955528d
chore(oie): ASVS 5.0 provisional B2 sources and gold
northdpole Sep 29, 2026
86d320a
chore(oie): NIST 800-53 and remaining B2 sources/gold
northdpole Sep 29, 2026
62cedd4
feat(mappings): promote Related-orphan remaps into canonical fixtures
northdpole Sep 29, 2026
81faa70
Address review feedback on full-pipeline runner.
northdpole Oct 5, 2026
53562bf
feat(librarian): batch Module C query embeddings
northdpole Oct 7, 2026
657284b
fix(librarian): keep LLM SafetyGuard when restacking leaf-drilldown
northdpole Oct 7, 2026
ec9accd
fix(librarian): finish SafetyGuard + leaf-drilldown restack merge
northdpole Oct 7, 2026
e83b169
feat(oie): full-pipeline runner, docs, and experimental-flag notes
northdpole Sep 29, 2026
f180d0d
Add experimental OIE OWASP metadata agent for chat
cursoragent Oct 2, 2026
0b797a5
feat(librarian): promote d1-winner combo defaults (judge+cap8+top_k=3)
northdpole Sep 30, 2026
dfec9a8
Isolate OWASP meta concepts to chat and MCP only
cursoragent Oct 2, 2026
b3fce72
Add idempotent Alembic migration for OWASP agent meta tables.
northdpole Oct 14, 2026
a91d6e1
Fix OWASP agent probe gaps for chapters, people, membership, and CRE …
northdpole Oct 2, 2026
6953269
Add synth v2 probe suite and raise agent routing pass rate.
northdpole Oct 3, 2026
3c6bcff
Format owasp_agent modules with black for CI lint.
northdpole Oct 3, 2026
6da242e
Document OWASP agent setup, OIE relationship, and synth eval.
northdpole Oct 3, 2026
6d9eb6b
Black-format remaining owasp_agent modules for CI.
northdpole Oct 3, 2026
060e651
Answer OWASP entity chat probes from agent metadata.
northdpole Oct 12, 2026
8ce9b6c
Add multi-turn chat memory with New chat.
northdpole Oct 12, 2026
32aefc1
Harden OWASP agent routing for board, geo, CRE, and PG index.
northdpole Oct 14, 2026
e75479a
Route OWASP chat via multi-lane embedding similarity.
northdpole Oct 14, 2026
a69c0d3
Make OWASP agent meta embedding work on low-memory staging.
northdpole Oct 14, 2026
aeb2ebf
Add adversarial completion asker and align embed model ids.
northdpole Oct 14, 2026
033597b
Fix OWASP agent routing for chapter-in-city and project leaders.
northdpole Oct 14, 2026
34907f9
Treat named-chapter meetup asks as chapter lookup.
northdpole Oct 14, 2026
7a1cf7d
Reuse one Flask app in the adversarial completion asker.
northdpole Oct 14, 2026
3772492
feat(owasp-agent): sim-first retrieve with normalize, chapters, board…
northdpole Oct 15, 2026
1202fa4
fix(owasp-agent): stop substring event/chapter traps and city hardcodes
northdpole Oct 15, 2026
5369337
fix(owasp-agent): drop meta/normative keyword dump gates
northdpole Oct 15, 2026
b32ebbf
fix(owasp-agent): drop keyword dumps; derive project aliases on ingest
northdpole Oct 15, 2026
44dc468
chore(oie): trim #1088 for the staging rollout
northdpole Nov 1, 2026
692bc35
Merge remote-tracking branch 'origin/wip/oie-pipeline-eval-harness' i…
northdpole Nov 1, 2026
4074ac7
chore(harvester): trim #1115 for the staging rollout
northdpole Nov 1, 2026
1524c9f
Merge branch 'trim/1115' into trim/1116
northdpole Nov 1, 2026
f694b1c
chore(oie): trim #1116 and guard destructive eval scripts
northdpole Nov 1, 2026
71b6abd
Merge branch 'trim/1116' into trim/1117
northdpole Nov 1, 2026
866b86f
chore(oie): trim #1117 for the staging rollout
northdpole Nov 1, 2026
abe9547
Merge branch 'trim/1117' into trim/1118
northdpole Nov 1, 2026
fb4c782
chore(oie): trim #1118 for the staging rollout
northdpole Nov 1, 2026
adac09b
Merge branch 'trim/1118' into trim/1119
northdpole Nov 1, 2026
1a7c875
Merge branch 'trim/1119' into trim/1120
northdpole Nov 1, 2026
98d5c50
style: black-format llm_safety_guard.py
northdpole Nov 1, 2026
287cc1d
trim(#1120): fix merge-conflict markers, guard full pipeline, drop de…
northdpole Nov 1, 2026
b756876
Merge branch 'trim/1120' into trim/1125
northdpole Nov 1, 2026
8f1b203
Merge branch 'trim/1125' into trim/1127
northdpole Nov 1, 2026
d0e661c
trim(#1127): drop adversarial asker/batch scripts and canned CRE foll…
northdpole Nov 1, 2026
769401f
refactor(owasp-agent): move the meta-embedding push out of sync_all i…
northdpole Nov 1, 2026
c9dae24
chore: drop generated frontend bundle (rebuild at deploy)
northdpole Nov 1, 2026
b07a6d9
chore(owasp-agent): type embed_sync and its test
northdpole Nov 1, 2026
cf93371
test(owasp-agent): sync and concepts must not import application.data…
northdpole Nov 1, 2026
823027a
test(owasp-agent): restore the environment with a plain helper instea…
northdpole Nov 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
27 changes: 25 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ 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.
OWASP_AGENT_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

# Embeddings

NO_GEN_EMBEDDINGS=false
Expand All @@ -52,14 +64,25 @@ GOOGLE_CLIENT_SECRET=your-client-secret
GOOGLE_SECRET_JSON=path/to/secret.json
LOGIN_ALLOWED_DOMAINS=example.com

# GCP
# GCP / Gemini (optional — any LiteLLM provider works for Module B)

GCP_NATIVE=false
GEMINI_API_KEY=your-gemini-api-key
VERTEX_CHAT_MODEL=gemini-2.5-flash
VERTEX_EMBED_CONTENT_MODEL=gemini-embedding-001

# Noise / Relevance Filter (Module B)
# Other chat providers (LiteLLM). Set the key that matches CRE_NOISE_FILTER_LLM_MODEL.
# OPENAI_API_KEY=sk-...
# ANTHROPIC_API_KEY=sk-ant-...
# GROQ_API_KEY=gsk_...
# MISTRAL_API_KEY=...
# OPENROUTER_API_KEY=...

# Noise / Relevance Filter (Module B) — LiteLLM model id (provider/model)
# Examples: gemini/gemini-2.5-flash-lite | openai/gpt-4o-mini |
# anthropic/claude-haiku-4-5 | groq/llama-3.3-70b-versatile
# Any chat model LiteLLM supports; mid-size models usually work best
# (cheap + reliable for this classify gate — avoid tiny completion stubs).

CRE_NOISE_FILTER_LLM_MODEL=gemini/gemini-2.5-flash-lite
CRE_NOISE_FILTER_BATCH_SIZE=10
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,16 @@ standards_cache.sqlite
!docs/Mid_eval_blog_gsoc2026/module_B_mideval_blog.md
!docs/Final_eval_blog_gsoc2026/module_B_final_blog.md
!application/utils/librarian/README.md
!application/utils/owasp_agent/README.md
!docs/gsoc_2026_module_c/*.md
!docs/gsoc_2026_module_a/*.md
!docs/Final_eval_blog_gsoc2026/*.md
!docs/gsoc_2026_module_b/module_a_contract.md
!docs/gsoc_2026_module_b/module_c_contract.md
!docs/gsoc_2026_module_b/module_b_runbook.md
!docs/gsoc_2026_module_b/final_metrics.md
!docs/oie/*.md
!scripts/oie_owasp_eval/experiments/*.md

### Dev DBDumps
*.sql
Expand Down
39 changes: 36 additions & 3 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
.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

prod-run:
gunicorn cre:app --log-file=-
Expand Down Expand Up @@ -141,8 +141,12 @@ install-python:
make install-deps-python &&\
playwright install # Python embeddings/scraping (prompt_client); NOT frontend e2e — keep when migrating to Cypress

install-typescript:
yarn add webpack && cd application/frontend && yarn build
# Yarn install only. Do not `yarn add` or `yarn build` here: webpack is
# already in package.json, and a local build rewrites
# application/frontend/www/bundle.js (tracked so Heroku can serve the UI
# without a Node compile step). That was dirtying contributor trees after
# `make install`. Rebuild with `make frontend` when you change the UI.
install-typescript: install-deps-typescript

install: install-typescript install-python migrate-upgrade

Expand Down Expand Up @@ -185,10 +189,39 @@ oie-pipeline:
[ -d "./venv" ] && . ./venv/bin/activate &&\
PYTHONPATH=. python scripts/run_oie_pipeline.py --cache_file "$(or $(CACHE_FILE),sqlite:///$(CURDIR)/standards_cache.sqlite)" $(OIE_ARGS)

# Deterministic OIE base metadata (Node then CRE document_metadata.oie). Fill-if-missing.
# Example:
# make oie-tag-base CACHE_FILE=postgresql://cre:password@127.0.0.1:5432/cre_prodclone
oie-tag-base:
[ -d "./venv" ] && . ./venv/bin/activate &&\
PYTHONPATH=. python scripts/oie_ensure_base_metadata.py \
--cache-file "$(or $(CACHE_FILE),$(or $(DEV_DATABASE_URL),postgresql://cre:password@127.0.0.1:5432/cre))" \
$(OIE_TAG_ARGS)

# Local OIE bootstrap: start cre-postgres, migrate, sync CRE hub (local|upstream).
# Examples:
# make setup-oie
# make setup-oie SETUP_OIE_ARGS='--source upstream --install-ml --calibrate'
setup-oie:
bash ./scripts/setup_oie.sh $(SETUP_OIE_ARGS)

oie-e2e-smoke:
[ -d "./venv" ] && . ./venv/bin/activate &&\
PYTHONPATH=. python scripts/run_oie_e2e_smoke.py

owasp-agent-sync:
[ -d "./venv" ] && . ./venv/bin/activate &&\
PYTHONPATH=. python scripts/owasp_agent_sync.py $(OWASP_AGENT_SYNC_ARGS)

owasp-agent-merge-concepts:
[ -d "./venv" ] && . ./venv/bin/activate &&\
PYTHONPATH=. python scripts/owasp_agent_merge_concepts.py $(OWASP_AGENT_MERGE_ARGS)

# Score fixtures/owasp_agent_synth_v2.jsonl against OWASP_AGENT_DB (see application/utils/owasp_agent/README.md).
owasp-agent-synth-eval:
[ -d "./venv" ] && . ./venv/bin/activate &&\
OWASP_AGENT_ENABLED=1 PYTHONPATH=. python scripts/owasp_agent_synth_eval.py

openapi-generate:
[ -d "./venv" ] && . ./venv/bin/activate &&\
python scripts/generate_openapi.py
Expand Down
5 changes: 5 additions & 0 deletions application/database/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ class Embeddings(BaseModel): # type: ignore
# vectors (legacy CSV ``embeddings`` column is dropped in that migration).
# SQLite/tests: Text holding a pgvector literal ``[1.0,2.0,...]``.
embedding_vec = sqla.Column(sqla.Text, nullable=False)
# Multi-lane chat routing: cre_graph | corpus | owasp_agent_meta
# (Alembic c9d0e1f2a3b4). Nullable for legacy rows until backfilled.
source_channel = sqla.Column(sqla.String, nullable=True, default=None)


class GapAnalysisResults(BaseModel):
Expand Down Expand Up @@ -3112,6 +3115,7 @@ def add_embedding(
embedding_model_id=embedding_model_id,
embedding_dim=embedding_dim,
embedding_vec=embedding_vec_literal,
source_channel="cre_graph",
)
else:
emb = Embeddings(
Expand All @@ -3122,6 +3126,7 @@ def add_embedding(
embedding_model_id=embedding_model_id,
embedding_dim=embedding_dim,
embedding_vec=embedding_vec_literal,
source_channel="corpus",
)
self.session.add(emb)
self.session.commit()
Expand Down
14 changes: 10 additions & 4 deletions application/frontend/src/pages/chatbot/chatbot.scss
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ h1.ui.header.chatbot-title {
margin-bottom: 1rem !important;
}

.chatbot-toolbar {
display: flex;
justify-content: center;
margin: 0 auto 0.5rem;
max-width: 960px;
}

/* Tablet & below */
@media (max-width: 768px) {
h1.ui.header.chatbot-title {
Expand Down Expand Up @@ -270,7 +277,7 @@ h1.ui.header.chatbot-title {

margin-top: 1rem;
background-color: #daebdb;
/* background: transparent; */
/* background: transparent; */
border: 1px solid rgb(190, 214, 232);
padding: 0.75rem;
border-radius: 12px;
Expand Down Expand Up @@ -399,7 +406,7 @@ h1.ui.header.chatbot-title {
flex-direction: column;
height: 100%;

background: #fcfcfa; /* same palette as input */
background: #fcfcfa; /* same palette as input */
backdrop-filter: blur(6px);

border-radius: 18px;
Expand Down Expand Up @@ -434,7 +441,6 @@ h1.ui.header.chatbot-title {
========================= */

@keyframes typingBounce {

0%,
80%,
100% {
Expand Down Expand Up @@ -470,4 +476,4 @@ h1.ui.header.chatbot-title {
opacity: 0.85;
transform: translateX(-50%) translateY(0);
}
}
}
70 changes: 68 additions & 2 deletions application/frontend/src/pages/chatbot/chatbot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const Chatbot = () => {
message: string;
data: Document[] | null;
accurate: boolean;
owaspCitations?: string[];
};

interface ChatState {
Expand Down Expand Up @@ -135,6 +136,16 @@ export const Chatbot = () => {
return res;
}

const HISTORY_CAP = 20;

function startNewChat() {
setChatMessages([]);
setError('');
setChat(DEFAULT_CHAT_STATE);
setModelName('');
setShowScrollToBottom(false);
}

async function onSubmit() {
if (!chat.term.trim()) return;
shouldForceScrollRef.current = true;
Expand All @@ -143,6 +154,12 @@ export const Chatbot = () => {
setChat({ ...chat, term: '' });
setLoading(true);

const prior = chatMessages.slice(-(HISTORY_CAP - 1)).map((m) => ({
role: m.role === 'assistant' ? 'assistant' : 'user',
content: m.message,
}));
const messages = [...prior, { role: 'user', content: currentTerm }];

setChatMessages((prev) => [
...prev,
{
Expand All @@ -157,7 +174,7 @@ export const Chatbot = () => {
fetch(`${apiUrl}/completion`, {
method: 'POST',
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
body: JSON.stringify({ prompt: currentTerm }),
body: JSON.stringify({ prompt: currentTerm, messages }),
})
.then(async (response) => {
if (!response.ok) {
Expand Down Expand Up @@ -187,8 +204,17 @@ export const Chatbot = () => {
timestamp: new Date().toLocaleTimeString(),
role: 'assistant',
message: data.response,
data: data.table,
// CRE RAG citations only — never treat owasp_agent hits as graph nodes.
data: Array.isArray(data.table)
? data.table.filter(
(d: Document) =>
d &&
d.doctype &&
!['owaspmeta', 'owasp_meta', 'concept'].includes(String(d.doctype).toLowerCase())
)
: data.table,
accurate: data.accurate,
owaspCitations: Array.isArray(data?.owasp_agent?.citations) ? data.owasp_agent.citations : [],
},
]);
})
Expand All @@ -201,6 +227,11 @@ export const Chatbot = () => {

function displayDocument(d: Document) {
if (!d || !d.doctype) return null;
// Never present non-CRE / meta-shaped payloads as OpenCRE graph nodes.
const dt = String(d.doctype).toLowerCase();
if (dt === 'owaspmeta' || dt === 'owasp_meta' || dt === 'concept') {
return null;
}

let link = `/node/${d.doctype.toLowerCase()}/${d.name}`;
link += d.section ? `/section/${d.section}` : `/sectionid/${d.sectionID}`;
Expand All @@ -224,6 +255,30 @@ export const Chatbot = () => {
);
}

function displayOwaspCitations(urls: string[]) {
const safe = urls.filter((url) => {
try {
const parsed = new URL(url);
return parsed.protocol === 'http:' || parsed.protocol === 'https:';
} catch {
return false;
}
});
if (!safe.length) return null;
return (
<div className="references">
<div className="references-title">OWASP community sources</div>
{safe.map((url, i) => (
<div className="reference-card" key={i}>
<a href={url} target="_blank" rel="noopener noreferrer">
{url}
</a>
</div>
))}
</div>
);
}

return (
<>
{/* user login check moved to useEffect */}
Expand All @@ -233,6 +288,13 @@ export const Chatbot = () => {
<Header as="h1" className="chatbot-title">
OWASP OpenCRE Chat
</Header>
{hasMessages ? (
<div className="chatbot-toolbar">
<Button type="button" size="small" basic onClick={startNewChat}>
<Icon name="plus" /> New chat
</Button>
</div>
) : null}

<Container>
<div className={`chat-container ${hasMessages ? 'chat-active' : 'chat-landing'}`}>
Expand Down Expand Up @@ -264,6 +326,10 @@ export const Chatbot = () => {
</div>
)}

{m.owaspCitations && m.owaspCitations.length > 0
? displayOwaspCitations(m.owaspCitations)
: null}

{!m.accurate && (
<div className="accuracy-warning">
This answer could not be fully verified against OpenCRE sources. Please validate
Expand Down
Loading
Loading