Skip to content

Commit e3a0475

Browse files
author
Dilan Bhalla
committed
msft extractor queries
1 parent 54d9eda commit e3a0475

File tree

9 files changed

+155
-0
lines changed

9 files changed

+155
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @name Extraction errors msft
3+
* @description List all extraction errors for files in the source code directory.
4+
* @kind diagnostic
5+
* @id cpp/diagnostics/extraction-errors
6+
*/
7+
8+
import cpp
9+
import ExtractionErrors
10+
11+
from ExtractionError error
12+
select error.getFile(), error.getErrorMessage()
13+
14+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @name Extraction error msft
3+
* @description An error message reported by the extractor, limited to those files where there are no
4+
* compilation errors. This indicates a bug or limitation in the extractor, and could lead
5+
* to inaccurate results.
6+
* @kind diagnostic
7+
* @id cs/extraction-error-msft
8+
* @tags security
9+
*/
10+
11+
import csharp
12+
import semmle.code.csharp.commons.Diagnostics
13+
14+
from ExtractorError error
15+
select error.getLocation().getFile(), error.getText()
16+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* @id go/diagnostics/extraction-errors-msft
3+
* @name Extraction errors msft
4+
* @description List all extraction errors for files in the source code directory.
5+
* @kind diagnostic
6+
*/
7+
8+
import go
9+
import semmle.go.DiagnosticsReporting
10+
11+
// Go does not have warnings, so all errors have error severity
12+
predicate reportableDiagnosticsMsft(Diagnostic d, File f, string msg) {
13+
// Only report errors for files that would have been extracted
14+
f = d.getFile() and
15+
exists(f.getAChild()) and
16+
msg = removeAbsolutePaths(d.getMessage())
17+
}
18+
19+
from Diagnostic d, File f, string msg
20+
where reportableDiagnostics(d, f, msg)
21+
select f, msg
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* @name Extraction errors msft
3+
* @description A list of extraction errors for files in the source code directory.
4+
* @kind diagnostic
5+
* @id java/diagnostics/extraction-errors-msft
6+
*/
7+
8+
import java
9+
import DiagnosticsReporting
10+
11+
private predicate knownErrorsMsft(Diagnostic d, File f, string msg) {
12+
d.getSeverity() = [6, 7, 8] and
13+
f = d.getLocation().getFile()
14+
msg = d.getMessage()
15+
}
16+
17+
private predicate unknownErrorsMsft(Diagnostic d, File f, string msg) {
18+
not knownErrors(d, _, _) and
19+
d.getSeverity() > 3 and
20+
d.getLocation().getFile() = f and
21+
exists(f.getRelativePath()) and
22+
msg = "Unknown error"
23+
}
24+
25+
from Diagnostic d, File f, string msg
26+
where
27+
knownErrorsMsft(Diagnostic d, File f, string msg) or
28+
unknownErrorsMsft(Diagnostic d, File f, string msg)
29+
select f, msg
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* @name Extraction errors msft
3+
* @description List all extraction errors for files in the source code directory.
4+
* @kind diagnostic
5+
* @id js/diagnostics/extraction-errors-msft
6+
*/
7+
8+
import javascript
9+
10+
from Error error
11+
where
12+
exists(error.getFile().getRelativePath()) and
13+
error.isFatal()
14+
select error.getFile(), error.getMessage()
15+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* @name Python extraction warnings msft
3+
* @description List all extraction warnings for Python files in the source code directory.
4+
* @kind diagnostic
5+
* @id py/diagnostics/extraction-warnings-msft
6+
*/
7+
8+
import python
9+
10+
from SyntaxError error, File file
11+
where
12+
file = error.getFile() and
13+
exists(file.getRelativePath())
14+
select file, error.getMessage()
15+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @name Extraction errors msft
3+
* @description List all extraction errors for files in the source code directory.
4+
* @kind diagnostic
5+
* @id rb/diagnostics/extraction-errors-msft
6+
*/
7+
8+
import codeql.ruby.AST
9+
import codeql.ruby.Diagnostics
10+
11+
from ExtractionError error, File f
12+
where
13+
f = error.getLocation().getFile() and
14+
exists(f.getRelativePath())
15+
select f, error.getMessage()
16+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @name Extraction errors msft
3+
* @description List all extraction errors for files in the source code directory.
4+
* @kind diagnostic
5+
* @id rust/diagnostics/extraction-errors-msft
6+
*/
7+
8+
import codeql.rust.Diagnostics
9+
import codeql.files.FileSystem
10+
11+
from ExtractionError error, File f
12+
where
13+
f = error.getLocation().getFile() and
14+
exists(f.getRelativePath())
15+
select f, error.getMessage()
16+
17+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* @name Compiler errors msft
3+
* @description List all compiler errors for files in the source code directory.
4+
* @kind diagnostic
5+
* @id swift/diagnostics/extraction-errors-msft
6+
*/
7+
8+
import swift
9+
10+
from CompilerError error
11+
select error.getFile(), error.getText()
12+

0 commit comments

Comments
 (0)