Repository navigation
Fake agent raising pr comments automatically - #203
niharika3715 wants to merge 13 commits into
Conversation
|
|
||
| # Link to code-scanning alerts | ||
| body_lines+=("") | ||
| body_lines+=("[View code-scanning alerts](${{ env.REPO_OWNER }}/${{ env.REPO_NAME }}/security/code-scanning)") |
There was a problem hiding this comment.
false positive that is safe. and same comment is coming twice please check
|
|
||
| # Link to code-scanning alerts | ||
| body_lines+=("") | ||
| body_lines+=("[View code-scanning alerts](${{ env.REPO_OWNER }}/${{ env.REPO_NAME }}/security/code-scanning)") |
There was a problem hiding this comment.
false positive that is safe.
vsn411
left a comment
There was a problem hiding this comment.
Thanks for taking on #108, and for testing it end to end on a scratch repo. That is exactly the proof the issue asks for. The fake-agent idea and the sticky-comment flow are the right shape. Some of the action logic needs another pass before this can merge, though, and a few items from the issue are still open. The list below goes in order of importance.
Must fix
-
The comment content is hard-coded.
- "Findings gate: Passed", "Cost gate: Passed" and "AI spend: $0.00" are fixed strings, so a PR whose gate failed would still get a comment saying "Passed".
- The "fallback" row (
SAST … 1 / 1 / 1 / 1 | $0.00) is added every time the result file exists. - The Python heredoc prints the real per-skill rows to the step log, not into
body_lines, so they never reach the comment.
Suggestion: build the whole body in one Python script from
secfoo-result.json, write it to a file, and post it withgh api … -F [email protected]. Main's "Run secfoo" step already does most of this for the job summary: the per-skill table and the gate lines fromdoc["gates"]. The cost isdoc["total_cost_usd"]. -
Exit-code handling.
exit "$code"in the scan step, together with removing the "Apply secfoo's exit code" step, means a tripped gate skips everything after the scan. You can see it in this PR's selftest log:Export SARIF … outcome=skipped. That loses the SARIF upload and the comment exactly when they matter.- Keep main's deferred
exit 0and the final "Apply exit code" step. - Give the comment step
if: ${{ !cancelled() && ... }}so it runs when the gate fails.
- Keep main's deferred
-
The fake agent can't work from a PyPI install.
FakeAdapterreadsparents[3]/tests/fixtures/ci/fake-report.md, buttests/isn't in the wheel. So the selftest would stay red even after a release.AgentId.FAKEis added to the CLI enum for everyone, so--agent fakeshows insecfoo run --help, but withoutSECFOO_FAKE_AGENT=1it fails.
Suggestions:
- Add an action input such as
install-from(empty = PyPI, as today). The selftest passesinstall-from: ., so it tests this PR's code. That also removes the "will pass after the next release" problem. - Have the fake adapter read the report from a path in an env var (e.g.
SECFOO_FAKE_REPORT), which the selftest sets totests/fixtures/ci/fake-report.md. - Accept
fakeonly whenSECFOO_FAKE_AGENT=1, and keep it out of--helpandsecfoo agents, as the issue says.
-
extra-argsis appended twice. The new block before the skills loop duplicates the one main already has further down. Please drop the new one. -
Cache.
- The key is fixed per branch.
actions/cacheentries are immutable, so after the first save the store never updates. Use a unique key with a prefix restore, e.g.key: secfoo-${{ github.repository }}-${{ github.ref_name }}-${{ github.run_id }}andrestore-keys: secfoo-${{ github.repository }}-${{ github.ref_name }}-. - The
cache-keyinput isn't used:env: cache-key:on auses:step doesn't change the key. - The
${{ runner.os }}-secfoo-restore key would pull in another branch's store. - Please exclude the files that can hold credentials (
!~/.secfoo/memory.toml,!~/.secfoo/config.toml). - Please pin
actions/cacheto a commit SHA like the other actions inaction.yml.
- The key is fixed per branch.
-
Links.
- The docs link to
https://github.com/secfoo-com/secfoo/security/code-scanningreturns 404 to anonymous users, which is whyDocs (links, version)fails. Please describe the link instead of linking this repo's alerts page. - In the comment,
${{ env.REPO_OWNER }}/${{ env.REPO_NAME }}/security/code-scanningis a relative URL. Use$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/security/code-scanningfrom the environment, without${{ }}insiderun:.
- The docs link to
Smaller things
github-tokendefaults to empty, soghhas no token. Please default it to${{ github.token }}.- The comment step says it must never fail the job but uses
set -e.set -uo pipefailwith the existing|| echo "::notice::…"is enough. - The
if [ -d "$HOME/.secfoo" ] … : else : fiblock does nothing, so please remove it. With--json,secfoo runalways scans and never prompts, so--rescancan simply stay as it was. The docs line "New findings may appear as closed" isn't right either. tests/fixtures/ci/fake-report.mdends with a strayEOFline, and several files have no trailing newline.
Still open from #108
- The four exit-code jobs (0, 1, 2, 3).
- SARIF validation against the 2.1.0 schema.
actionlintin CI.
Splitting the PR
This is a lot for one PR, and splitting it would get your work merged sooner:
- Fake agent,
install-from, self-test workflow with the exit-code jobs, and actionlint. - Sticky PR comment.
- Cache.
Each would be small enough to review and merge in a day. We'd be glad to see the first one up whenever you're ready, and happy to help if anything here is unclear.
Closes #108
What does this change, and why?
Completes the GitHub Action integration by adding an automated self-test workflow, sticky PR comments, cached findings storage, YAML linting, and updated documentation.
The action can now be tested automatically on pull requests, retain findings between runs, and provide security scan results directly in PR comments.
Code Flow
Temporary changes for testing
After testing: We reverted the installation change. Once the PR is merged and the package is published, the fake agent will be available in the package.
Reason for failed Checks
Testing
pytest testspassesruff check .passesactionlintpassesdummy pr that is tested: niharika3715/upskill-tracker#1