Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed Extraction Queries #146

Merged
merged 2 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions cpp/ql/src/Diagnostics/ExtractorErrorMsft.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* @name Extraction errors msft
* @description List all extraction errors for files in the source code directory.
* @id cpp/extractor-error-msft
* @kind problem
* @tags security
* extraction
*/

import cpp
import ExtractionErrors

from ExtractionError error
select error.getFile(), error.getErrorMessage()


17 changes: 17 additions & 0 deletions csharp/ql/src/Diagnostics/ExtractorErrorMsft.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @name Extraction error msft
* @description An error message reported by the extractor, limited to those files where there are no
* compilation errors. This indicates a bug or limitation in the extractor, and could lead
* to inaccurate results.
* @id cs/extractor-error-msft
* @kind problem
* @tags security
* extraction
*/

import csharp
import semmle.code.csharp.commons.Diagnostics

from ExtractorError error
select error.getLocation().getFile(), error.getText()

23 changes: 23 additions & 0 deletions go/ql/src/Diagnostics/ExtractorErrorMsft.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* @name Extraction errors msft
* @description List all extraction errors for files in the source code directory.
* @id go/extractor-error-msft
* @kind problem
* @tags security
* extraction
*/

import go
import semmle.go.DiagnosticsReporting

// Go does not have warnings, so all errors have error severity
predicate reportableDiagnosticsMsft(Diagnostic d, File f, string msg) {
// Only report errors for files that would have been extracted
f = d.getFile() and
exists(f.getAChild()) and
msg = removeAbsolutePaths(d.getMessage())
}

from Diagnostic d, File f, string msg
where reportableDiagnostics(d, f, msg)
select f, msg
31 changes: 31 additions & 0 deletions java/ql/src/Diagnostics/ExtractionErrorMsft.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* @name Extraction errors msft
* @description A list of extraction errors for files in the source code directory.
* @id java/extractor-error-msft
* @kind problem
* @tags security
* extraction
*/

import java
import DiagnosticsReporting

private predicate knownErrorsMsft(Diagnostic d, File f, string msg) {
d.getSeverity() = [6, 7, 8] and
f = d.getLocation().getFile()
msg = d.getMessage()
}

private predicate unknownErrorsMsft(Diagnostic d, File f, string msg) {
not knownErrors(d, _, _) and
d.getSeverity() > 3 and
d.getLocation().getFile() = f and
exists(f.getRelativePath()) and
msg = "Unknown error"
}

from Diagnostic d, File f, string msg
where
knownErrorsMsft(Diagnostic d, File f, string msg) or
unknownErrorsMsft(Diagnostic d, File f, string msg)
select f, msg
17 changes: 17 additions & 0 deletions javascript/ql/src/Diagnostics/ExtractionErrorMsft.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @name Extraction errors msft
* @description List all extraction errors for files in the source code directory.
* @id js/extractor-error-msft
* @kind problem
* @tags security
* extraction
*/

import javascript

from Error error
where
exists(error.getFile().getRelativePath()) and
error.isFatal()
select error.getFile(), error.getMessage()

17 changes: 17 additions & 0 deletions python/ql/src/Diagnostics/ExtractorErrorMsft.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @name Python extraction warnings msft
* @description List all extraction warnings for Python files in the source code directory.
* @id py/extractor-error-msft
* @kind problem
* @tags security
* extraction
*/

import python

from SyntaxError error, File file
where
file = error.getFile() and
exists(file.getRelativePath())
select file, error.getMessage()

18 changes: 18 additions & 0 deletions ruby/ql/src/queries/diagnostics/ExtractorErrorMsft.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* @name Extraction errors msft
* @description List all extraction errors for files in the source code directory.
* @id rb/extractor-error-msft
* @kind problem
* @tags security
* extraction
*/

import codeql.ruby.AST
import codeql.ruby.Diagnostics

from ExtractionError error, File f
where
f = error.getLocation().getFile() and
exists(f.getRelativePath())
select f, error.getMessage()

19 changes: 19 additions & 0 deletions rust/ql/src/queries/diagnostics/ExtractorErrorMsft.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* @name Extraction errors msft
* @description List all extraction errors for files in the source code directory.
* @id rust/extractor-error-msft
* @kind problem
* @tags security
* extraction
*/

import codeql.rust.Diagnostics
import codeql.files.FileSystem

from ExtractionError error, File f
where
f = error.getLocation().getFile() and
exists(f.getRelativePath())
select f, error.getMessage()


14 changes: 14 additions & 0 deletions swift/ql/src/diagnostics/ExtractorErrorMsft.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* @name Compiler errors msft
* @description List all compiler errors for files in the source code directory.
* @id swift/extractor-error-msft
* @kind problem
* @tags security
* extraction
*/

import swift

from CompilerError error
select error.getFile(), error.getText()

Loading