@windyroad/risk-scorer 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,6 +18,16 @@ if [ -z "$SESSION_ID" ] || [ -z "$FILE_PATH" ]; then
18
18
  exit 0
19
19
  fi
20
20
 
21
+ # P004: Only gate files inside the project root.
22
+ case "$FILE_PATH" in
23
+ /*)
24
+ case "$FILE_PATH" in
25
+ "$PWD"/*) ;;
26
+ *) exit 0 ;;
27
+ esac
28
+ ;;
29
+ esac
30
+
21
31
  # Only gate RISK-POLICY.md
22
32
  BASENAME=$(basename "$FILE_PATH")
23
33
  if [ "$BASENAME" != "RISK-POLICY.md" ]; then
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env bats
2
+
3
+ # P004: risk-policy-enforce-edit.sh project-root check.
4
+
5
+ setup() {
6
+ SCRIPT_DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")/.." && pwd)"
7
+ HOOK="$SCRIPT_DIR/risk-policy-enforce-edit.sh"
8
+ }
9
+
10
+ run_hook_with_file() {
11
+ local file_path="$1"
12
+ local json="{\"tool_input\":{\"file_path\":\"${file_path}\"},\"session_id\":\"test-$$\"}"
13
+ echo "$json" | bash "$HOOK"
14
+ }
15
+
16
+ @test "risk-policy project-root: RISK-POLICY.md outside project exits 0" {
17
+ run run_hook_with_file "/Users/other/project/RISK-POLICY.md"
18
+ [ "$status" -eq 0 ]
19
+ [[ "$output" != *"BLOCKED"* ]]
20
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@windyroad/risk-scorer",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Pipeline risk scoring, commit/push gates, and secret leak detection",
5
5
  "bin": {
6
6
  "windyroad-risk-scorer": "./bin/install.mjs"