mirror of
https://github.com/github/codeql.git
synced 2026-04-25 16:55:19 +02:00
Emit diagnostic to pass fourth integration tests
This commit is contained in:
@@ -143,3 +143,13 @@ func EmitNewerGoVersionNeeded() {
|
||||
"", 0, 0, 0, 0,
|
||||
)
|
||||
}
|
||||
|
||||
func EmitGoFilesFoundButNotProcessed() {
|
||||
emitDiagnostic("go/autobuilder/go-files-found-but-not-processed",
|
||||
"Go files were found but not processed",
|
||||
"[Specify a custom build command](https://docs.github.com/en/github-ae@latest/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-the-codeql-workflow-for-compiled-languages#adding-build-steps-for-a-compiled-language) that includes one or more `go build` commands to build the `.go` files to be analyzed.",
|
||||
severityError, false,
|
||||
true, true, true,
|
||||
"", 0, 0, 0, 0,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -98,6 +98,15 @@ func ExtractWithFlags(buildFlags []string, patterns []string) error {
|
||||
|
||||
if len(pkgs) == 0 {
|
||||
log.Println("No packages found.")
|
||||
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
log.Fatalf("Unable to determine current directory: %s\n", err.Error())
|
||||
}
|
||||
|
||||
if util.FindGoFiles(wd) {
|
||||
diagnostics.EmitGoFilesFoundButNotProcessed()
|
||||
}
|
||||
}
|
||||
|
||||
log.Println("Extracting universe scope.")
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"io/fs"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
@@ -281,3 +282,17 @@ func EscapeTrapSpecialChars(s string) string {
|
||||
s = strings.ReplaceAll(s, "#", "#")
|
||||
return s
|
||||
}
|
||||
|
||||
func FindGoFiles(root string) bool {
|
||||
found := false
|
||||
filepath.WalkDir(root, func(s string, d fs.DirEntry, e error) error {
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
if filepath.Ext(d.Name()) == ".go" {
|
||||
found = true
|
||||
}
|
||||
return nil
|
||||
})
|
||||
return found
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user