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
9 changes: 6 additions & 3 deletions internal/scan/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,13 +349,16 @@ func (a *Agent) whyExcluded(it model.ScanItem) model.ExcludeReason {
if a.args.FileFilter != nil && a.args.FileFilter.IsUserExcluded(path) {
return model.ExcludeUserRule
}
// User-include is checked before the extension allowlist (matching the
// preview/diff path in internal/agent) so an explicit include glob can
// admit otherwise-unsupported extensions (e.g. .ftl). See #371.
if a.args.FileFilter != nil && a.args.FileFilter.HasInclude() && a.args.FileFilter.IsUserIncluded(path) {
return model.ExcludeNone
}
ext := extFromPath(path)
if ext != "" && !allowedext.IsAllowedExt(ext) {
return model.ExcludeExtension
}
if a.args.FileFilter != nil && a.args.FileFilter.HasInclude() && a.args.FileFilter.IsUserIncluded(path) {
return model.ExcludeNone
}
if allowedext.IsExcludedPath(path) {
return model.ExcludeDefaultPath
}
Expand Down
10 changes: 10 additions & 0 deletions internal/scan/coverage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,16 @@ func TestWhyExcluded_AllBranches(t *testing.T) {
filter: &rules.FileFilter{Include: []string{"src/**"}},
want: model.ExcludeNone,
},
{
// #371: a user-include glob must override the built-in extension
// allowlist (as it already does on the preview/diff path). A
// non-allowlisted extension (.ftl) with a matching include glob
// must be included, not rejected as ExcludeExtension.
name: "user include overrides extension allowlist",
item: model.ScanItem{Path: "templates/email.ftl", Content: "x"},
filter: &rules.FileFilter{Include: []string{"**/*.ftl"}},
want: model.ExcludeNone,
},
{
name: "default excluded path",
item: model.ScanItem{Path: "pkg/handler_test.go", Content: "x"},
Expand Down