Skip to content
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
with:
fetch-depth: 0

Expand All @@ -24,7 +24,7 @@ jobs:
grep -q "fetch-depth: 0" action.yml

- name: Set up Python
uses: actions/setup-python@v6
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: "3.12"

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ If you develop the SDK in the same repo, use the composite action in [UnplugAI/U
## Local CLI

```bash
pip install "unplug-ai>=0.4.0"
pip install "unplug-ai>=0.4.0,<0.5"
unplug-scan-pr --base-ref main
```

Expand Down
18 changes: 15 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Unplug Agent Scan
description: Scan changed agent and MCP config files in PRs with unplug-ai (regex-only Guard). Use actions/checkout with fetch-depth: 0 so origin/<base-ref> exists.
description: "Scan changed agent and MCP config files in PRs with unplug-ai (regex-only Guard). Use actions/checkout with fetch-depth: 0 so origin/<base-ref> exists."
author: UnplugAI
branding:
icon: shield
Expand All @@ -23,13 +23,13 @@ runs:
using: composite
steps:
- name: Set up uv
uses: astral-sh/setup-uv@v7
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7
with:
enable-cache: true
version: "0.6.14"

- name: Set up Python
uses: actions/setup-python@v6
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: ${{ inputs.python-version }}

Expand All @@ -39,6 +39,18 @@ runs:
UNPLUG_VERSION: ${{ inputs.unplug-version }}
run: uv pip install --system "unplug-ai${UNPLUG_VERSION}"

# Fail closed if the base ref is missing (shallow checkout / wrong branch).
# Without this, the diff would be empty and the scan would silently pass.
- name: Verify base ref is available
shell: bash
env:
BASE_REF: ${{ inputs.base-ref }}
run: |
if ! git rev-parse --verify --quiet "origin/${BASE_REF}^{commit}" >/dev/null; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Revision Syntax Bypasses Ref Check

When base-ref contains git revision syntax such as main^ or main~1, this check verifies origin/main^ as a valid commit instead of requiring the literal remote branch origin/main. The scan then runs against the caller-supplied revision expression, which can expand the diff to commits outside the PR and produce incorrect scan results.

Fix in Claude Code

echo "::error title=Unplug scan misconfigured::'origin/${BASE_REF}' not found. Check out with actions/checkout and 'fetch-depth: 0', and set 'base-ref' to the PR base branch (received '${BASE_REF}'). Refusing to scan an empty/incorrect diff."
exit 1
fi

- name: Scan changed agent files
shell: bash
env:
Expand Down