Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ jobs:
run: pnpm run build

- name: Publish to GitHub Packages
continue-on-error: true
run: |
echo "@ritualdev-lab:registry=https://npm.pkg.github.com" > .npmrc
echo "//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}" >> .npmrc
Expand Down
8 changes: 8 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ inputs:
description: "Path to export OASIS SARIF 2.1.0 report (for GitHub Code Scanning upload-sarif)"
required: false
default: ".agentshield.sarif"
strict:
description: "Enforce immutable security root policy (--strict) preventing untrusted PR ignore rules from neutering secret scans (default: true)"
required: false
default: "true"

runs:
using: "composite"
Expand All @@ -40,9 +44,13 @@ runs:
INPUT_POST_PR_COMMENT: ${{ inputs.post_pr_comment }}
INPUT_ANNOTATE_DIFF: ${{ inputs.annotate_diff }}
INPUT_SARIF_FILE: ${{ inputs.sarif_file }}
INPUT_STRICT: ${{ inputs.strict }}
ACTION_PATH: ${{ github.action_path }}
run: |
EXTRA_FLAGS=""
if [ "$INPUT_STRICT" = "true" ]; then
EXTRA_FLAGS="$EXTRA_FLAGS --strict"
fi
if [ "$INPUT_ANNOTATE_DIFF" = "true" ]; then
EXTRA_FLAGS="$EXTRA_FLAGS --annotate"
fi
Expand Down
35 changes: 34 additions & 1 deletion src/ci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,43 @@ export class CiGateRunner {
let configTampered = false;

const configTouched = rawDiffList.some((f) =>
/(?:^\.?agentshield(?:\.config)?\.json$)/i.test(f),
/(?:^\.?agentshield(?:\.config)?\.json$|^\.agentshieldignore$)/i.test(f),
);

if (configTouched) {
// Fail-closed check: reject blanket wildcard ignores in .agentshieldignore (SEC-02)
const ignoreTouched = rawDiffList.some((f) => /^\.agentshieldignore$/i.test(f));
if (ignoreTouched) {
try {
const ignoreContent = readFileSync(`${this.rootDir}/.agentshieldignore`, "utf8");
const maliciousGlob = ignoreContent
.split("\n")
.map((l) => l.trim())
.some(
(l) =>
l &&
!l.startsWith("#") &&
(l === "*" || l === "**/*" || l === "**/.*" || /^!\s*secrets\b/i.test(l)),
);
if (maliciousGlob) {
return {
passed: false,
totalSecrets: 0,
criticalCount: 1,
highCount: 0,
filesScanned: rawDiffList.length,
findings: [],
markdownReport:
"## 🛡️ AgentShield CI/CD Security Gate Report\n\n### 🚨 Fatal Policy Violation (--strict): Malicious Blanket Ignore Detected in `.agentshieldignore`\nPR attempted to add blanket wildcard/inverted ignore rules (`*`, `**/*`, `**/.*`). Merging blocked.",
scanError: "Malicious wildcard glob detected in .agentshieldignore (--strict)",
baseRef: sanitizedBase,
configTampered: true,
};
}
} catch {
// Ignore if deleted
}
}
try {
const baseConfigRaw = execFileSync("git", ["show", `${sanitizedBase}:.agentshield.json`], {
encoding: "utf8",
Expand Down
Loading