Go: apply path transformer for file TRAP labels

This commit is contained in:
Nick Rolfe
2025-09-08 14:32:53 +01:00
parent 4c009d5bc9
commit dd4f27868e
2 changed files with 4 additions and 3 deletions

View File

@@ -814,12 +814,12 @@ func (extraction *Extraction) extractFileInfo(tw *trap.Writer, file string, isDu
displayPath = rawPath
}
if i == len(components)-1 {
lbl := tw.Labeler.FileLabelFor(file)
lbl := tw.Labeler.FileLabelFor(path)
dbscheme.FilesTable.Emit(tw, lbl, displayPath)
dbscheme.ContainerParentTable.Emit(tw, parentLbl, lbl)
dbscheme.HasLocationTable.Emit(tw, lbl, emitLocation(tw, lbl, 0, 0, 0, 0))
extraction.Lock.Lock()
slbl := extraction.StatWriter.Labeler.FileLabelFor(file)
slbl := extraction.StatWriter.Labeler.FileLabelFor(path)
if !isDummy {
dbscheme.CompilationCompilingFilesTable.Emit(extraction.StatWriter, extraction.Label, extraction.GetFileIdx(file), slbl)
}

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"go/types"
"github.com/github/codeql-go/extractor/srcarchive"
"github.com/github/codeql-go/extractor/util"
)
@@ -67,7 +68,7 @@ func (l *Labeler) GlobalID(key string) Label {
// FileLabel returns the label for a file with path `path`.
func (l *Labeler) FileLabel() Label {
if l.fileLabel == InvalidLabel {
l.fileLabel = l.FileLabelFor(l.tw.path)
l.fileLabel = l.FileLabelFor(srcarchive.TransformPath(l.tw.path))
}
return l.fileLabel
}