Skip to content

Graph-Native Infrastructure for Context and Accountable AI Systems

fix(ci): handle pip-audit skipped dependencies, restore manual trigger, fix stale docs

KaifAhmad1b5199ae6e3a9
diff --git a/.github/workflows/security-scan.yml b/.github/workflows/security-scan.yml
index 7d8a3eb4..d60bfd0d 100644
--- a/.github/workflows/security-scan.yml
+++ b/.github/workflows/security-scan.yml
@@ -3,6 +3,7 @@ name: Security Scan
on:
schedule:
- cron: '30 1 * * 1,4' # Mon/Thu 7 AM IST
+ workflow_dispatch:
push:
branches: [main]
paths-ignore:
@@ -77,17 +78,33 @@ jobs:
# Guard 2: fail closed when the report doesn't have the shape the
# checks below assume: a non-empty dependencies array, each entry
- # carrying an array-valued vulns field.
+ # either carrying an array-valued vulns field or being a dependency
+ # pip-audit couldn't resolve/audit, which it reports as
+ # {"name": ..., "skip_reason": ...} with no vulns field at all
+ # (see pip_audit._format.json.JsonFormat._format_dep). That's a
+ # normal, documented report shape, not a malformed one — treating
+ # it as invalid would fail the whole job over a single unauditable
+ # package, the same kind of scan-unrelated CI break this migration
+ # away from Safety was meant to fix.
if ! jq -e '
(.dependencies | type == "array" and length > 0)
- and all(.dependencies[]; type == "object" and (.vulns | type == "array"))
+ and all(.dependencies[]; type == "object" and ((.vulns | type == "array") or (.skip_reason | type == "string")))
' pip-audit-report.json >/dev/null 2>&1; then
- echo "::error::pip-audit report has an invalid dependency structure. Expected a non-empty dependencies array with a vulns array for every dependency. Treating as failure."
+ echo "::error::pip-audit report has an invalid dependency structure. Expected a non-empty dependencies array where every entry has either a vulns array or a skip_reason. Treating as failure."
exit 1
fi
echo "Checking for package vulnerabilities..."
+ # Guard 2 above already confirmed pip-audit-report.json is valid
+ # JSON with a well-shaped dependencies array, so this count is
+ # always a plain non-negative integer.
+ SKIPPED=$(jq '[.dependencies[] | select(has("skip_reason"))] | length' pip-audit-report.json)
+ if [ "$SKIPPED" -gt 0 ]; then
+ echo "⚠️ pip-audit could not audit $SKIPPED dependencies (see pip-audit-report.json for skip_reason):"
+ jq -r '.dependencies[] | select(has("skip_reason")) | " - \(.name): \(.skip_reason)"' pip-audit-report.json
+ fi
+
# Vulnerability IDs reviewed and accepted as non-actionable for this
# project. Empty for now: pip-audit's OSV-backed database doesn't
# currently carry either of the findings Safety used to flag here
@@ -107,9 +124,13 @@ jobs:
# No []? / || echo "0" fallback: if jq fails (malformed JSON) VULNS
# will be empty or "null" so Guard 3 below catches it rather than
# silently treating the broken report as zero.
+ # `.vulns // []` guards against skipped dependencies, which carry
+ # no vulns field at all (see the skip_reason handling above) -
+ # without the fallback, iterating `null[]` raises inside jq and
+ # this whole computation silently evaluates to empty.
VULNS=$(jq --arg ignored "$IGNORED_VULN_IDS" '
($ignored | split(",") | map(select(length > 0))) as $ignore_list
- | [.dependencies[].vulns[] | select(.id as $id | ($ignore_list | index($id)) | not)]
+ | [.dependencies[] | (.vulns // [])[] | select(.id as $id | ($ignore_list | index($id)) | not)]
| length
' pip-audit-report.json 2>/dev/null)
@@ -130,7 +151,7 @@ jobs:
jq --arg ignored "$IGNORED_VULN_IDS" -r '
($ignored | split(",") | map(select(length > 0))) as $ignore_list
| .dependencies[] as $dependency
- | $dependency.vulns[] | select(.id as $id | ($ignore_list | index($id)) | not)
+ | ($dependency.vulns // [])[] | select(.id as $id | ($ignore_list | index($id)) | not)
| "- \($dependency.name)==\($dependency.version): \(.id)"
' pip-audit-report.json || true
exit 1
@@ -241,6 +262,24 @@ jobs:
.map((id) => id.trim())
.filter(Boolean);
+ // A dependency pip-audit couldn't resolve/audit is reported as
+ // {"name": ..., "skip_reason": ...} with no vulns field at all
+ // (see pip_audit._format.json.JsonFormat._format_dep) - that's a
+ // normal report shape, not a malformed one, so it must not be
+ // treated as an invalid dependency below.
+ const isSkipped = (dependency) => typeof dependency.skip_reason === 'string';
+
+ let skippedDeps = [];
+ try {
+ const auditData = JSON.parse(fs.readFileSync('pip-audit-report.json', 'utf8'));
+ skippedDeps = (auditData.dependencies || []).filter(
+ (dependency) => dependency && typeof dependency === 'object' && isSkipped(dependency)
+ );
+ } catch (e) {
+ // Unreadable/unparseable report - renderSection's own
+ // report-missing branch below surfaces this.
+ }
+
const pipAuditSection = renderSection(
'pip-audit — dependency vulnerabilities',
'pip-audit-report.json',
@@ -252,14 +291,14 @@ jobs:
(dependency) =>
!dependency ||
typeof dependency !== 'object' ||
- !Array.isArray(dependency.vulns)
+ (!Array.isArray(dependency.vulns) && !isSkipped(dependency))
)
) {
return null;
}
return data.dependencies.flatMap((dependency) =>
- dependency.vulns
+ (dependency.vulns || [])
.filter((vulnerability) => !ignoredVulnIds.includes(vulnerability.id))
.map(
(vulnerability) => `- \`${dependency.name}==${dependency.version}\`: ${vulnerability.id}` +
@@ -269,6 +308,8 @@ jobs:
}
) + (ignoredVulnIds.length
? `\n\n_Excluded as accepted, non-actionable findings: ${ignoredVulnIds.join(', ')} — see the workflow file's inline comments for why._`
+ : '') + (skippedDeps.length
+ ? `\n\n_Could not be audited: ${skippedDeps.map((d) => `\`${d.name}\` (${d.skip_reason})`).join(', ')}_`
: '');
const banditSection = renderSection(
diff --git a/SECURITY.md b/SECURITY.md
index 6b395811..b4d5bc30 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -153,7 +153,7 @@ that attack chain.
- **Risk**: a PR merges without its security/CI checks passing.
**Control**: merges require the `build`, `Analyze Python` (CodeQL), and `security-scan` checks to pass, in strict mode (checks must be re-run against the latest `main`).
- **Risk**: a compromised scanner job reaches secrets or write access.
- **Control**: scanning jobs (`CodeQL`, `security-scan.yml`, `security.yml`, `defender-for-devops.yml`) run with read-only, least-privilege permissions (typically `contents: read` + `security-events: write` only) and never share a job, environment, or secret scope with the publish job.
+ **Control**: scanning jobs (`CodeQL`, `security-scan.yml`, `defender-for-devops.yml`) run with read-only, least-privilege permissions (typically `contents: read` + `security-events: write` only) and never share a job, environment, or secret scope with the publish job.
- **Risk**: secrets are committed accidentally.
**Control**: GitHub secret scanning and push protection are both enabled at the repository level, rejecting pushes that contain recognizable credential patterns before they land in history.
@@ -164,8 +164,7 @@ Every scan below runs continuously in CI, not just at release time:
- **CodeQL** (`security-and-quality` query pack) — Python source: injection, unsafe deserialization, and other code-level vulnerability classes. Runs in `codeql.yml` on every push/PR to `main` and weekly.
- **Bandit** — Python-specific security anti-patterns (hardcoded secrets, unsafe `eval`/`pickle`, weak crypto, etc.); CI fails on any HIGH-severity finding. Runs in `security-scan.yml` on every push/PR to `main` and twice weekly.
- **Semgrep** (`p/security` ruleset) — cross-language static-analysis security patterns. Runs in `security-scan.yml` on every push/PR to `main` and twice weekly.
-- **Safety** — known CVEs in Semantica's own installed dependencies, including optional LLM-provider extras such as LiteLLM; CI fails on any match. Runs in `security-scan.yml` on every push/PR to `main` and twice weekly.
-- **pip-audit** — independent, PyPA-maintained vulnerability database cross-check against installed dependencies (Safety and pip-audit use different advisory sources, so both run). Runs in `security.yml` weekly.
+- **pip-audit** — PyPA-maintained, OSV-backed vulnerability database cross-check against Semantica's pinned dependency tree, including optional LLM-provider extras such as LiteLLM; CI fails on any match. Runs in `security-scan.yml` on every push/PR to `main` and twice weekly, and can be triggered on demand via `workflow_dispatch`.
- **Microsoft Defender for DevOps** (`eslint`, `templateanalyzer`, `terrascan`) — JavaScript/TypeScript lint-security rules and infrastructure-as-code misconfigurations. Runs in `defender-for-devops.yml` on every push/PR to `main` and weekly.
- **Checkov** — Kubernetes, Helm, Dockerfile, GitHub Actions, and secrets-pattern IaC scanning; results upload to the same Security tab as CodeQL. Runs in `defender-for-devops.yml` on every push/PR to `main` and weekly.
- **GitGuardian** — secret-detection check on every pull request, installed as a GitHub App integration (not a repo-local workflow). Runs on every PR.