Skip to content

Commit 1d60cd7

Browse files
committed
Go: recognize CODEQL_PATH_TRANSFORMER env var
1 parent 5d7a739 commit 1d60cd7

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

go/extractor/cli/go-autobuilder/go-autobuilder.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ func createPathTransformerFile(newdir string) *os.File {
273273
log.Fatalf("Failed to chdir into %s: %s\n", newdir, err.Error())
274274
}
275275

276-
// set up SEMMLE_PATH_TRANSFORMER to ensure paths in the source archive and the snapshot
276+
// set up CODEQL_PATH_TRANSFORMER to ensure paths in the source archive and the snapshot
277277
// match the original source location, not the location we moved it to
278278
pt, err := os.CreateTemp("", "path-transformer")
279279
if err != nil {
@@ -292,9 +292,9 @@ func writePathTransformerFile(pt *os.File, realSrc, root, newdir string) {
292292
if err != nil {
293293
log.Fatalf("Unable to close path transformer file: %s.", err.Error())
294294
}
295-
err = os.Setenv("SEMMLE_PATH_TRANSFORMER", pt.Name())
295+
err = os.Setenv("CODEQL_PATH_TRANSFORMER", pt.Name())
296296
if err != nil {
297-
log.Fatalf("Unable to set SEMMLE_PATH_TRANSFORMER environment variable: %s.\n", err.Error())
297+
log.Fatalf("Unable to set CODEQL_PATH_TRANSFORMER environment variable: %s.\n", err.Error())
298298
}
299299
}
300300

@@ -501,7 +501,8 @@ func installDependenciesAndBuild() {
501501

502502
srcdir := getSourceDir()
503503

504-
// we set `SEMMLE_PATH_TRANSFORMER` ourselves in some cases, so blank it out first for consistency
504+
// we set `CODEQL_PATH_TRANSFORMER` ourselves in some cases, so blank it out first for consistency
505+
os.Setenv("CODEQL_PATH_TRANSFORMER", "")
505506
os.Setenv("SEMMLE_PATH_TRANSFORMER", "")
506507

507508
// determine how to install dependencies and whether a GOPATH needs to be set up before

go/extractor/srcarchive/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/extractor/srcarchive/srcarchive.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ import (
77
"os"
88
"path/filepath"
99
"strings"
10+
11+
"github.com/github/codeql-go/extractor/util"
1012
)
1113

1214
var pathTransformer *ProjectLayout
1315

1416
func init() {
15-
pt := os.Getenv("SEMMLE_PATH_TRANSFORMER")
17+
pt := util.Getenv("CODEQL_PATH_TRANSFORMER", "SEMMLE_PATH_TRANSFORMER")
1618
if pt != "" {
1719
ptf, err := os.Open(pt)
1820
if err != nil {
@@ -69,7 +71,7 @@ func srcArchive() (string, error) {
6971
return srcArchive, nil
7072
}
7173

72-
// TransformPath applies the transformations specified by `SEMMLE_PATH_TRANSFORMER` (if any) to the
74+
// TransformPath applies the transformations specified by `CODEQL_PATH_TRANSFORMER` (if any) to the
7375
// given path
7476
func TransformPath(path string) string {
7577
if pathTransformer != nil {

0 commit comments

Comments
 (0)