diff --git a/checks/denylisted-imports.go b/checks/denylisted-imports.go index 6a0cf58..7fcb137 100644 --- a/checks/denylisted-imports.go +++ b/checks/denylisted-imports.go @@ -11,7 +11,7 @@ import ( ) var ( - deniedImports = []string{"io/ioutil", "encoding/json"} + deniedImports = []string{"io/ioutil", "encoding/json", "gitea.com/gitea/go-crypto"} DenylistImports = &analysis.Analyzer{ Name: "denylist_imports", Doc: "check for denied imports", @@ -26,7 +26,7 @@ func runDenylistImports(pass *analysis.Pass) (interface{}, error) { val = strings.TrimPrefix(val, `"`) val = strings.TrimSuffix(val, `"`) for _, deniedImport := range deniedImports { - if deniedImport == val { + if strings.HasPrefix(val, deniedImport) { // Allow a exemption when there is a comment 'Allow "package_name" import' allowed := false for _, comment := range file.Comments { @@ -37,7 +37,7 @@ func runDenylistImports(pass *analysis.Pass) (interface{}, error) { } if !allowed { - pass.Reportf(im.Path.Pos(), `"`+deniedImport+"\" is not allowed to be imported") + pass.Reportf(im.Path.Pos(), `"`+val+"\" is not allowed to be imported") } } }