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
8 changes: 4 additions & 4 deletions bots/gsbot/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions robot-repo-automaton/src/confidence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,7 @@ fn is_protected_file(target: &str) -> bool {
"spec/",
"verification/",
];
if protected_dirs.iter().any(|dir| target.contains(dir)) {
return true;
}

false
protected_dirs.iter().any(|dir| target.contains(dir))
}

/// Check if a file is a standard repository file (high confidence to create)
Expand Down
60 changes: 60 additions & 0 deletions robot-repo-automaton/tests/confidence_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// SPDX-License-Identifier: MPL-2.0
//! Regression tests for the confidence guard on protected directories.

use robot_repo_automaton::catalog::{Fix, FixAction, Severity};
use robot_repo_automaton::{ConfidenceLevel, DetectedIssue, ThresholdConfig};

fn deletion_confidence(target: &str) -> ConfidenceLevel {
let issue = DetectedIssue {
error_type_id: "TEST".into(),
error_name: "Obsolete file".into(),
severity: Severity::Medium,
description: "Detected an obsolete file".into(),
affected_files: vec![],
confidence: 1.0,
suggested_fix: "Delete the file".into(),
commit_message: "fix: remove obsolete file".into(),
};
let fix = Fix {
action: FixAction::Delete,
target: target.into(),
reason: None,
modification: None,
fallback: None,
};
ThresholdConfig::default().classify_fix(&issue, &fix)
}

#[test]
fn test_high_confidence_deletes_are_downgraded_in_protected_directories() {
// No protected basename or extension can account for these results.
for target in [
".machine_readable/metadata.json",
"crates/engine/src/abi/exports.rs",
"docs/getting-started.txt",
"packages/engine/spec/grammar.txt",
"verification/run.sh",
] {
assert_eq!(
deletion_confidence(target),
ConfidenceLevel::Low,
"{target}"
);
}
}

#[test]
fn test_high_confidence_deletes_keep_their_rating_for_directory_near_misses() {
for target in [
"src/docs", // A filename, with no trailing directory separator.
"docs-old/notes.txt",
"packages/engine/Spec/grammar.txt", // Directory markers are case sensitive.
"crates/engine/src/abigail/exports.rs",
] {
assert_eq!(
deletion_confidence(target),
ConfidenceLevel::High,
"{target}"
);
}
}
4 changes: 2 additions & 2 deletions scripts/lib/lock-closure-receipts.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ metadatastician/standards ea2f4d8a886585ed442687ae63d4ad7493379ba4 oven-sh/setup
# Reviewed source: hyperpolymath/proven-cicd-and-workflows/.github/workflows/secret-scanner-reusable.yml@1fd5e6371a50f0fc3687206a5adca0cdf7b39aa6
hyperpolymath/proven-cicd-and-workflows 1fd5e6371a50f0fc3687206a5adca0cdf7b39aa6 actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1

# Reviewed source: hyperpolymath/hypatia/.github/workflows/credential-read-check.yml@29a9e4a881b6a3cc4cd27fcbc0886ffbadcbc5fe
hyperpolymath/hypatia 29a9e4a881b6a3cc4cd27fcbc0886ffbadcbc5fe step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a
# Reviewed source: hyperpolymath/hypatia/.github/workflows/credential-read-check.yml@f2c0604880f615bec5edda7aaefc8feac3d04cc5
hyperpolymath/hypatia f2c0604880f615bec5edda7aaefc8feac3d04cc5 step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a
2 changes: 1 addition & 1 deletion scripts/lib/pinned-reusable-sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@
},
{
"repository": "hyperpolymath/hypatia",
"commit": "29a9e4a881b6a3cc4cd27fcbc0886ffbadcbc5fe",
"commit": "f2c0604880f615bec5edda7aaefc8feac3d04cc5",
"path": ".github/workflows/credential-read-check.yml",
"blob": "15c597ea720a5affb861dab058084f7245ee4cbd",
"content_sha256": "645e8ac8ff118c33f2dc941ec46f1abac895f7836339736841c269e4b9dc084d",
Expand Down
22 changes: 19 additions & 3 deletions scripts/tests/pinned-reusable-sources-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ replace_pin() {
done
}
check() {
local label="$1" expected="$2" rc=0 valid=0
local label="$1" expected="$2" expected_rule="${3:-}" rc=0 valid=0
timeout 15s bash "$HELPER" --json --repo-root "$CASE/repo" --manifest "$MANIFEST" \
--lock "$CASE/repo/.github/workflows/actions.lock" --receipts "$CASE/repo/receipts.tsv" --cache "$CASE/cache" \
> "$CASE/result.json" 2> "$CASE/stderr" || rc=$?
if jq -e 'type=="object" and (.findings|type=="array") and (.not_run|type=="array") and (.verified_roots|type=="array") and (.verified_receipt_sources|type=="array")' "$CASE/result.json" >/dev/null 2>&1; then
case "$expected" in
clean) [[ "$rc" == 0 ]] && jq -e '(.findings|length)==0 and (.not_run|length)==0 and (.verified_roots|length)==1 and (.verified_receipt_sources|length)>0' "$CASE/result.json" >/dev/null && valid=1 ;;
fatal) [[ "$rc" == 1 || "$rc" == 3 ]] && jq -e 'any(.findings[]; .severity=="FATAL" and (.rule|length)>0 and (.detail|length)>0) and (.verified_roots|length)==0 and (.verified_receipt_sources|length)==0' "$CASE/result.json" >/dev/null && valid=1 ;;
fatal) [[ "$rc" == 1 || "$rc" == 3 ]] && jq -e --arg rule "$expected_rule" 'any(.findings[]; .severity=="FATAL" and (.rule|length)>0 and ($rule=="" or .rule==$rule) and (.detail|length)>0) and (.verified_roots|length)==0 and (.verified_receipt_sources|length)==0' "$CASE/result.json" >/dev/null && valid=1 ;;
notrun) [[ "$rc" == 2 ]] && jq -e '(.findings|length)==0 and any(.not_run[]; (.rule|length)>0 and (.detail|length)>0) and (.verified_roots|length)==0 and (.verified_receipt_sources|length)==0' "$CASE/result.json" >/dev/null && valid=1 ;;
*) printf 'Unexpected fixture expectation: %s\n' "$expected" >&2; exit 64 ;;
esac
Expand Down Expand Up @@ -115,6 +115,22 @@ fi
[[ -f "$HELPER" ]] || { echo 'Missing helper; this is a prerequisite failure, not a successful rejection control.' >&2; exit 64; }

case_fixture good; check 'authenticated active source and exact receipt' clean

# A pin can move even when the reusable workflow and its direct edges are
# unchanged. The new caller pin still needs both current attestations.
case_fixture same-blob-repin
repin_tree="$(git --git-dir="$CASE/cache/org/reusable.git" rev-parse "$ROOT_SHA^{tree}")"
repin_sha="$(commit_tree "$CASE/cache/org/reusable.git" "$repin_tree" 'Repin unchanged workflow')"
[[ "$repin_sha" != "$ROOT_SHA" ]]
replace_pin "$ROOT_SHA" "$repin_sha"
check 'unchanged workflow authenticates after repinning caller, catalog and receipt' clean

cp "$BASE/repo/receipts.tsv" "$CASE/repo/receipts.tsv"
check 'unchanged workflow cannot use a receipt for the old pin' fatal SOURCE-RECEIPT
replace_pin "$ROOT_SHA" "$repin_sha"
edit_manifest --arg old "$ROOT_SHA" '.sources[0].commit=$old'
check 'unchanged workflow cannot use a catalog binding for the old pin' fatal SOURCE-ACTIVE-MISSING

case_fixture historical; edit_manifest '.sources += [(.sources[0] | .role="retained-review" | .callers=[] | .path=".github/workflows/other.yml")]'; check 'explicit historical review can coexist with active source' clean
case_fixture unrelated-vendor; cat >> "$CASE/repo/.github/workflows/actions.lock" <<YAML
'unrelated/action@v9':
Expand Down Expand Up @@ -269,4 +285,4 @@ for variant in main-good main-wrong-blob; do
else FAIL=$((FAIL+1)); printf 'FAIL: %s entrypoint did not enforce source authentication (exit %s)\n' "$variant" "$rc"; cat "$CASE/main.json" "$CASE/main.stderr"; fi
done
printf '\n%d passed, %d failed\n' "$PASS" "$FAIL"
[[ "$FAIL" == 0 ]]
[[ "$FAIL" == 0 ]]
Loading