Skip to content

feat: PR comment bot#15

Open
chaksaray wants to merge 18 commits into
developfrom
pr-commit-bot
Open

feat: PR comment bot#15
chaksaray wants to merge 18 commits into
developfrom
pr-commit-bot

Conversation

@chaksaray

Copy link
Copy Markdown
Member

integrate bawbel PR comment bot into PR

@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

chaksaray added 15 commits June 11, 2026 07:13
…s call

Removes the direct `from scanner.scanner import scan, SEVERITY_SCORES`
import (CLAUDE.md rule 5 violation) and replaces it with a subprocess
call to `bawbel scan --format json` using list form — the same contract
used by action.yml and the VS Code extension.

Adds tests/hooks/test_pre_commit.py with 14 tests covering: clean files,
threshold comparisons, GracefulDegradation (bawbel not installed → exit 0),
JSON parse errors, subprocess list-form enforcement, and a static AST
check that scanner.* is never imported.

Closes #17
…e/suppressions.ts

filterInlineIgnored is suppression logic — it belongs alongside isSuppressed,
addSuppression, and removeSuppression in core/suppressions.ts, not in the
rendering layer. Also fixes a latent bug in the original: the regex
excluded hyphens from capture, silently failing to match rule IDs like
bawbel-shell-pipe and AVE IDs like AVE-2026-00001.

While here: moves rawCache from module-level state to a private instance
property on DiagnosticsManager (closes #20), and replaces the inline
require("fs") with the top-level import already present in suppressions.ts.

Sets up vitest + vscode mock so TypeScript unit tests run without a VS Code
host. Adds 11 tests covering all bawbel-ignore comment formats and edge cases.

Closes #19
Replaces four separate python3 -c subprocess calls (each opening bawbel.yml
independently) with a single call to scripts/load_config.py. The script
reads bawbel.yml once, applies ConfigPriority (ActionInput > bawbel.yml >
default), and prints resolved key=value pairs that the action step pipes
directly to \$GITHUB_OUTPUT.

Adds 18 tests in tests/action/test_load_config.py covering: missing file,
malformed YAML, all four fields, boolean normalisation, ConfigPriority
override logic, and CLI output key format.

Closes #21
…line Python

Adds What/Why/How comments to all six logical sections of the inline Python
block in the "Post PR comment" step, plus a top-level Sec: block covering
the four security questions (INPUT/OUTPUT/TRUST/ERROR) for the whole script.

No functional changes. Removes one unused variable (fp) noticed while writing
the detail-parsing comment.

Closes #22
Pulls the severity→DiagnosticSeverity mapping out of buildActiveDiag
into a standalone exported function with a What/Why/How comment. The
function takes two numbers and returns an enum value — no VS Code state,
no side effects, fully testable without a mock extension host.

Also hardens the unknown-severity case: previously SEVERITY_INDEX lookup
could return undefined and coerce to NaN (always < threshold), now
explicitly defaults to 0 via the ?? operator so the behaviour is clear.

Adds 10 tests in src/test/features/diagnostics.test.ts covering all
threshold boundary combinations and the unknown-severity fallback.

Closes #23
pipx installs binaries to ~/.local/pipx/venvs/<package>/bin/<binary>,
not ~/.local/pipx/<package>/bin/<binary>. The missing venvs/ segment
meant the path never resolved, silently skipping pipx-installed bawbel
and requiring users to set bawbel.bawbelPath manually.

Also exports CANDIDATE_PATHS so the list can be verified in tests.
Adds 4 tests confirming the correct path is present, the wrong path
is absent, and the two other common install locations are covered.

Closes #24
…ing()

Adds 7 missing fields to BawbelFinding (owasp_mcp, aivss_score, aivss,
piranha_url, evidence_stage, confidence, derived) based on actual CLI output.
Makes line: number | null since file-level findings carry no line number.
Makes cvss_ai optional (not present in v1.2+ CLI output).
Adds AivssBreakdown interface for the nested aivss object.

Adds exported normaliseFinding() to parser.ts — the single seam where CLI
field names map to BawbelFinding; normaliseFileResult now calls it instead
of casting findings directly. 11 new tests in parser.test.ts.

Closes #25
… of renderDiagnostics()

renderDiagnostics() was called N times per scan batch, reading
.bawbel-suppress.json and VS Code config on every iteration.

Extract resolveFailSevIdx() private helper. applyResults() and
reRenderAll() now load suppressions and config once and pass them
into renderDiagnostics(suppressions, failSevIdx). reRender() (single
file) also loads once per call. 2 new tests verify the invariant.

Closes #26
…s and add Sec: block

filePath.split("/").pop() fails on Windows where the path separator
is backslash. Replace both occurrences with path.basename(filePath).

Add What/Why/How + Sec: block to show() per CLAUDE.md rule — it calls
runCommand() which spawns a subprocess.

Remove unused BawbelFileResult import.

Closes #27
…ppressions.ts

resolveGitUser() spawns git subprocess — CLAUDE.md requires a Sec: block
for any function that runs a subprocess. Replace JSDoc comment with
structured What/Why/How + Sec: format per project rules.

Closes #28
…valid SARIF

When bawbel scan crashes, times out, or is not installed, the redirect
`> bawbel-results.sarif` creates an empty or plain-text file. CodeQL's
upload-sarif then fails with "Unexpected end of JSON input".

After writing the SARIF, validate it with json.load(). If validation
fails, echo bawbel's stderr to the CI log and overwrite the file with a
minimal valid empty SARIF so upload-sarif always receives parseable input.

5 new tests in tests/action/test_sarif_fallback.py.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants