@@ -35,6 +35,24 @@ private class Diagnostic extends @diagnostic {
3535 string toString ( ) { result = this .getMessage ( ) }
3636}
3737
38+ bindingset [ msg]
39+ private string removeAbsolutePaths ( string msg ) {
40+ exists ( string r |
41+ // turn
42+ // cannot find package "subdir1/subsubdir1" in any of:\n\t/usr/local/Cellar/go/1.20.5/libexec/src/subdir1/subsubdir1 (from $GOROOT)\n\t/Users/owen-mc/go/src/subdir1/subsubdir1 (from $GOPATH)
43+ // into
44+ // cannot find package "subdir1/subsubdir1" in any of:\n\t(absolute path)/src/subdir1/subsubdir1 (from $GOROOT)\n\t(absolute path)/src/subdir1/subsubdir1 (from $GOPATH)
45+ r =
46+ "(cannot find package [^ ]* in any of:\\n\\t)/[^ ]*(/src/[^ ]* \\(from \\$GOROOT\\)\\n\\t)/[^ ]*(/src/[^ ]* \\(from \\$GOPATH\\))" and
47+ if exists ( msg .regexpCapture ( r , 1 ) )
48+ then
49+ result =
50+ msg .regexpCapture ( r , 1 ) + "(absolute path)" + msg .regexpCapture ( r , 2 ) + "(absolute path)" +
51+ msg .regexpCapture ( r , 3 )
52+ else result = msg
53+ )
54+ }
55+
3856/**
3957 * Holds if an extraction error or warning occurred that should be reported to end users,
4058 * with the error message `msg` and SARIF severity `sev`.
@@ -47,10 +65,11 @@ predicate reportableDiagnostics(Diagnostic d, string msg, int sev) {
4765 exists ( File f | f = d .getFile ( ) |
4866 exists ( f .getAChild ( ) ) and
4967 msg =
50- "Extraction failed in " + d .getFile ( ) .getRelativePath ( ) + " with error " + d .getMessage ( )
68+ "Extraction failed in " + d .getFile ( ) .getRelativePath ( ) + " with error " +
69+ removeAbsolutePaths ( d .getMessage ( ) )
5170 )
5271 or
5372 not exists ( d .getFile ( ) ) and
54- msg = "Extraction failed with error " + d .getMessage ( )
73+ msg = "Extraction failed with error " + removeAbsolutePaths ( d .getMessage ( ) )
5574 )
5675}
0 commit comments