Skip to content

fix(scan): check user include patterns before the extension allowlist#6

Open
chethanuk wants to merge 1 commit into
mainfrom
fix/issue-371-scan-include-order
Open

fix(scan): check user include patterns before the extension allowlist#6
chethanuk wants to merge 1 commit into
mainfrom
fix/issue-371-scan-include-order

Conversation

@chethanuk

@chethanuk chethanuk commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Description

In the full-scan path, user --include patterns were evaluated after the built-in extension allowlist, so a file with a non-allowlisted extension could never be force-included into a scan — even when the user explicitly asked for it. The preview path already evaluates user includes first, so ocr preview and the actual scan disagreed about which files a given --include selects.

This change moves the user-include check ahead of the extension-allowlist check in the scan path (internal/scan/agent.go), matching the preview path's decision order. Explicit user intent now wins over the built-in default in both places.

This also provides the "let users extend the allowlist themselves" escape hatch discussed in alibaba#371: --include "**/*.ftl" (or any other extension) now works for scans without a code change.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

How Has This Been Tested?

  • make test passes locally
  • Manual testing (describe below)

Coverage tests extended: a non-allowlisted extension matched by a user --include is now included in the scan (this case fails on the previous ordering), and existing exclusion behavior without --include is unchanged. make check (tidy + fmt + vet) passes.

Checklist

  • My code follows the project's coding style (go fmt, go vet)
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly (if applicable)

Related Issues

Related to alibaba#371 (complements the FreeMarker rules PR; makes the allowlist user-extensible via --include)

@codeant-ai codeant-ai Bot added the size:S This PR changes 10-29 lines, ignoring generated files label Jul 15, 2026
gemini-code-assist[bot]

This comment was marked as outdated.

The scan path evaluated the built-in extension allowlist before user
include globs, so an explicit include (e.g. **/*.ftl) could never force
a non-allowlisted extension into a scan — while the preview/diff path
already checks user includes first. The two paths disagreed about which
files the same include selects.

Reorders whyExcluded in scan/agent.go to match preview.go exactly:
binary, user-exclude, user-include, extension allowlist, default
excluded paths. User excludes still take precedence over includes, and
binary/size guards still run regardless. Adds a regression test: a .ftl
file with a matching include glob now yields ExcludeNone (fails on the
previous ordering).

Related to alibaba#371
@chethanuk
chethanuk force-pushed the fix/issue-371-scan-include-order branch from a7c3cd2 to 3eb7150 Compare July 15, 2026 09:14
Repository owner deleted a comment from codeant-ai Bot Jul 15, 2026
Repository owner deleted a comment from codeant-ai Bot Jul 15, 2026
Repository owner deleted a comment from coderabbitai Bot Jul 15, 2026
Repository owner deleted a comment from codeant-ai Bot Jul 15, 2026
@chethanuk chethanuk changed the title fix(scan): check user-include before extension allowlist fix(scan): check user include patterns before the extension allowlist Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant