-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathAlertSuppression.ql
More file actions
44 lines (35 loc) · 1.32 KB
/
AlertSuppression.ql
File metadata and controls
44 lines (35 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* @name Alert suppression
* @description Generates information about alert suppressions.
* @kind alert-suppression
* @id rust/alert-suppression
*/
private import codeql.util.suppression.AlertSuppression as AS
private import codeql.rust.elements.Comment as C
private import codeql.rust.elements.AstNode as A
class AstNode instanceof A::AstNode {
predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
super.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
string toString() { result = super.toString() }
}
class SingleLineComment instanceof C::Comment {
private string text;
SingleLineComment() {
// Match line comments (// or ///) and extract text after the marker
text = super.getText().regexpCapture("///?([^\\r\\n]*)", 1)
or
// Match single-line block comments (/* ... */ on one line)
text = super.getText().regexpCapture("/\\*([^\\r\\n]*)\\*/", 1)
}
predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
super.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
string getText() { result = text }
string toString() { result = super.toString() }
}
import AS::Make<AstNode, SingleLineComment>