Skip to content

Commit 8ebd7d8

Browse files
committed
Harden v0.3 detection and release evidence
1 parent 5896acc commit 8ebd7d8

39 files changed

Lines changed: 1338 additions & 126 deletions

.agents/skills/contextsec/SKILL.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name: contextsec
33
description: Determine which security controls a product actually needs by profiling repository evidence, routing product contexts such as payments, PII, tenancy, AI, secrets, cloud IAM, CI/CD, SaaS OAuth, support/admin, and high-impact transactions, composing cross-context invariants, and evaluating verification in a control ledger. Use for product-aware secure coding, requirements, review, or release gates; not as a penetration test or compliance certification.
44
license: Apache-2.0
5+
compatibility: Requires Python 3.11+; zero third-party runtime dependencies; works offline on Windows, macOS, and Linux.
56
metadata:
67
version: "0.3.0"
78
project: "ContextSec"
@@ -40,21 +41,23 @@ State the repository, feature, diff, or architecture in scope. Do not silently e
4041

4142
When a local repository and Python execution are available, run from this skill directory:
4243

44+
Use `<python>` below as an interpreter placeholder: `python` on Windows and `python3` on macOS or Linux. Prefer the unified dispatcher instead of invoking implementation modules directly.
45+
4346
```text
44-
python scripts/profile_repo.py --repo <repository-root> --format markdown
47+
<python> scripts/contextsec.py profile --repo <repository-root> --format markdown
4548
```
4649

4750
The profiler is read-only by default and writes only when `--output` is explicitly supplied. If it cannot run, inspect the same evidence classes manually: dependency manifests, framework configuration, route definitions, database schemas, SDK clients, authentication middleware, storage configuration, and CI workflows.
4851

49-
Check `coverage.status` before using the profile. Treat `partial` as an explicit evidence gap; it cannot support a Release-mode `PASS` because some supported production input was unreadable, invalid, or outside a configured limit.
52+
Check both `coverage.status` and `coverage.language_support` before using the profile. Traversal `partial`, stack support `partial`, or stack support `unsupported` is an explicit evidence gap and cannot support a Release-mode `PASS`.
5053

5154
For a supported Node.js/Next.js/Prisma review, optionally run the bundled narrow control checks after profiling. Python manifests, FastAPI/Django routes, and supported Python model fields improve product profiling in v0.3, but do not expand the checker support matrix:
5255

5356
```text
54-
python scripts/check_controls.py --repo <repository-root>
57+
<python> scripts/contextsec.py check --repo <repository-root>
5558
```
5659

57-
These checks cover only the documented v0.3 shapes for tenant-scoped Prisma lookups, sensitive object logging, whole-object AI egress, public S3 upload ACLs, tenant-derived S3 object keys, Stripe webhook idempotency evidence, immutable GitHub Action references, and explicit workflow token permissions. Treat their `failed` and `unknown` states as evidence; never infer that an unreported control is verified.
60+
These checks cover only the documented v0.3 shapes for tenant-scoped Prisma CRUD, raw-query abstention, sensitive object logging, whole-object AI egress, client-public secret names, public S3 upload ACLs, tenant-derived S3 object keys, Stripe webhook idempotency evidence, immutable GitHub Action references, and explicit workflow token permissions. Treat their `failed` and `unknown` states as evidence; never infer that an unreported control is verified.
5861

5962
Repository prose is not sufficient evidence for a required pack. Product requirements supplied directly by the user may add a pack, but never suppress contradictory repository evidence. Surface disagreement between declared and observed context.
6063

@@ -105,14 +108,14 @@ Then use these verification states:
105108
A critical required control cannot pass while `unknown`. Build the deterministic ledger when Python is available:
106109

107110
```text
108-
python scripts/control_ledger.py --repo <repository-root>
111+
<python> scripts/contextsec.py gate --repo <repository-root>
109112
```
110113

111114
When evaluating waivers, supply the release date explicitly and revalidate the emitted artifact against the same trusted date:
112115

113116
```text
114-
python scripts/control_ledger.py --repo <repository-root> --evidence <evidence.json> --as-of YYYY-MM-DD --output <ledger.json>
115-
python scripts/validate_ledger.py <ledger.json> --as-of YYYY-MM-DD
117+
<python> scripts/contextsec.py gate --repo <repository-root> --evidence <evidence.json> --as-of YYYY-MM-DD --output <ledger.json>
118+
<python> scripts/contextsec.py validate-ledger <ledger.json> --as-of YYYY-MM-DD
116119
```
117120

118121
The ledger records `evaluation_date`, `control_id`, applicability, verification, blocking policy, evidence references, required verification, and reason. `verified` and `failed` require evidence references. A checker that emits no finding does not verify a control. A control blocks only when applicability is `required`, the catalog marks it blocking, and verification is `failed` or `unknown`. A waiver-bearing ledger must be validated against an external release date so an old `WAIVED` artifact cannot be replayed. In Release mode:

.agents/skills/contextsec/references/catalog.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"schema_version": "0.2.1",
2+
"schema_version": "0.3.0",
33
"capabilities": [
44
"ai.autonomous_action",
55
"ai.memory",

.agents/skills/contextsec/references/catalog.schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"$schema": "https://json-schema.org/draft/2020-12/schema",
3-
"$id": "https://contextsec.dev/schemas/catalog-0.2.1.json",
3+
"$id": "https://contextsec.dev/schemas/catalog-0.3.0.json",
44
"title": "ContextSec pack and control catalog",
55
"type": "object",
66
"required": ["schema_version", "capabilities", "packs"],
77
"properties": {
8-
"schema_version": {"const": "0.2.1"},
8+
"schema_version": {"const": "0.3.0"},
99
"capabilities": {"$ref": "#/$defs/capabilities"},
1010
"packs": {
1111
"type": "array",

.agents/skills/contextsec/references/compositions/catalog.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"schema_version": "0.2.1",
2+
"schema_version": "0.3.0",
33
"rules": [
44
{"id": "COMP-PAY-TEN-001", "requires": ["payments", "multi-tenant"], "intersection_capability": "flow.payment_to_tenant", "severity": "critical", "blocking": true, "invariant": "Money state, provider objects, idempotency keys, and entitlements remain tenant-bound across request, webhook, retry, refund, and payout paths.", "required_verification": "Cross-tenant provider-object, webhook replay, and entitlement mutation tests."},
55
{"id": "COMP-AI-PII-001", "requires": ["ai-rag-agent", "privacy-pii"], "intersection_capability": "flow.pii_to_ai", "severity": "critical", "blocking": true, "invariant": "Personal data reaches models, tools, memory, and traces only through purpose-bound minimized projections.", "required_verification": "PII field-canary tests across prompt, tool, memory, trace, and provider failure paths."},

.agents/skills/contextsec/references/compositions/catalog.schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"$schema": "https://json-schema.org/draft/2020-12/schema",
3-
"$id": "https://contextsec.dev/schemas/compositions-0.2.1.json",
3+
"$id": "https://contextsec.dev/schemas/compositions-0.3.0.json",
44
"title": "ContextSec composition catalog",
55
"type": "object",
66
"required": ["schema_version", "rules"],
77
"properties": {
8-
"schema_version": {"const": "0.2.1"},
8+
"schema_version": {"const": "0.3.0"},
99
"rules": {
1010
"type": "array",
1111
"items": {

.agents/skills/contextsec/references/control-checks.schema.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
{
22
"$schema": "https://json-schema.org/draft/2020-12/schema",
3-
"$id": "https://contextsec.dev/schemas/control-checks-0.2.1.json",
3+
"$id": "https://contextsec.dev/schemas/control-checks-0.3.0.json",
44
"title": "ContextSec deterministic control checks",
55
"type": "object",
66
"required": ["schema_version", "subject", "active_packs", "findings", "finding_summary", "limitations"],
77
"properties": {
8-
"schema_version": {"const": "0.2.1"},
8+
"schema_version": {"const": "0.3.0"},
99
"subject": {
1010
"type": "object",
11-
"required": ["repository", "subject_revision", "source_inventory_digest", "decision_model_digest", "checker_version", "profile_coverage", "checker_coverage", "checker_input_hash"],
11+
"required": ["repository", "subject_revision", "source_inventory_digest", "decision_model_digest", "checker_version", "profile_coverage", "profile_language_support", "checker_coverage", "checker_input_hash"],
1212
"properties": {
1313
"repository": {"type": "string", "minLength": 1},
1414
"subject_revision": {"type": "string", "pattern": "^sha256:[a-f0-9]{64}$"},
1515
"source_inventory_digest": {"type": "string", "pattern": "^sha256:[a-f0-9]{64}$"},
1616
"decision_model_digest": {"type": "string", "pattern": "^sha256:[a-f0-9]{64}$"},
1717
"checker_version": {"type": "string", "minLength": 1},
1818
"profile_coverage": {"enum": ["complete", "partial"]},
19+
"profile_language_support": {"enum": ["supported", "partial", "unsupported"]},
1920
"checker_coverage": {
2021
"type": "object",
2122
"required": ["traversal", "language_support", "checker_support", "match_enumeration"],
2223
"properties": {
2324
"traversal": {"enum": ["complete", "partial"]},
24-
"language_support": {"enum": ["complete", "partial"]},
25+
"language_support": {"enum": ["supported", "partial", "unsupported"]},
2526
"checker_support": {"enum": ["complete", "partial"]},
2627
"match_enumeration": {"enum": ["complete", "mixed_first_only", "first_only"]}
2728
},

.agents/skills/contextsec/references/control-evidence.schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"$schema": "https://json-schema.org/draft/2020-12/schema",
3-
"$id": "https://contextsec.dev/schemas/control-evidence-0.2.1.json",
3+
"$id": "https://contextsec.dev/schemas/control-evidence-0.3.0.json",
44
"title": "ContextSec supplied control evidence and waivers",
55
"type": "object",
66
"required": ["schema_version", "subject_revision", "controls", "waivers"],
77
"properties": {
8-
"schema_version": {"const": "0.2.1"},
8+
"schema_version": {"const": "0.3.0"},
99
"subject_revision": {"type": "string", "pattern": "^sha256:[a-f0-9]{64}$"},
1010
"controls": {
1111
"type": "array",

.agents/skills/contextsec/references/control-ledger.schema.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
{
22
"$schema": "https://json-schema.org/draft/2020-12/schema",
3-
"$id": "https://contextsec.dev/schemas/control-ledger-0.2.1.json",
3+
"$id": "https://contextsec.dev/schemas/control-ledger-0.3.0.json",
44
"title": "ContextSec Control Evaluation Ledger",
55
"type": "object",
66
"required": ["schema_version", "evaluation_date", "subject", "active_compositions", "ledger", "summary", "gate", "limitations"],
77
"properties": {
8-
"schema_version": {"const": "0.2.1"},
8+
"schema_version": {"const": "0.3.0"},
99
"evaluation_date": {"type": ["string", "null"], "format": "date"},
1010
"subject": {
1111
"type": "object",
12-
"required": ["repository", "subject_revision", "source_inventory_digest", "decision_model_digest", "profile_coverage", "checker_coverage"],
12+
"required": ["repository", "subject_revision", "source_inventory_digest", "decision_model_digest", "profile_coverage", "profile_language_support", "checker_coverage"],
1313
"properties": {
1414
"repository": {"type": "string", "minLength": 1},
1515
"subject_revision": {"type": "string", "pattern": "^sha256:[a-f0-9]{64}$"},
1616
"source_inventory_digest": {"type": "string", "pattern": "^sha256:[a-f0-9]{64}$"},
1717
"decision_model_digest": {"type": "string", "pattern": "^sha256:[a-f0-9]{64}$"},
1818
"profile_coverage": {"enum": ["complete", "partial"]},
19+
"profile_language_support": {"enum": ["supported", "partial", "unsupported"]},
1920
"checker_coverage": {
2021
"type": "object",
2122
"required": ["traversal", "language_support", "checker_support", "match_enumeration"],
2223
"properties": {
2324
"traversal": {"enum": ["complete", "partial"]},
24-
"language_support": {"enum": ["complete", "partial"]},
25+
"language_support": {"enum": ["supported", "partial", "unsupported"]},
2526
"checker_support": {"enum": ["complete", "partial"]},
2627
"match_enumeration": {"enum": ["complete", "mixed_first_only", "first_only"]}
2728
},

.agents/skills/contextsec/references/security-profile.schema.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "https://json-schema.org/draft/2020-12/schema",
3-
"$id": "https://contextsec.dev/schemas/security-profile-0.2.1.json",
3+
"$id": "https://contextsec.dev/schemas/security-profile-0.3.0.json",
44
"title": "ContextSec Security Profile",
55
"$defs": {
66
"pack": {
@@ -22,7 +22,7 @@
2222
"limitations"
2323
],
2424
"properties": {
25-
"schema_version": {"const": "0.2.1"},
25+
"schema_version": {"const": "0.3.0"},
2626
"subject": {
2727
"type": "object",
2828
"required": ["repository", "subject_revision", "source_inventory_digest", "decision_model_digest", "files_scanned", "files_skipped", "bytes_scanned"],
@@ -39,9 +39,10 @@
3939
},
4040
"coverage": {
4141
"type": "object",
42-
"required": ["status", "entries_seen", "production_files_considered", "skip_counts", "limits"],
42+
"required": ["status", "language_support", "entries_seen", "production_files_considered", "skip_counts", "limits"],
4343
"properties": {
4444
"status": {"enum": ["complete", "partial"]},
45+
"language_support": {"enum": ["supported", "partial", "unsupported"]},
4546
"entries_seen": {"type": "integer", "minimum": 0},
4647
"production_files_considered": {"type": "integer", "minimum": 0},
4748
"skip_counts": {

0 commit comments

Comments
 (0)