-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathConcepts.qll
More file actions
75 lines (65 loc) · 2.54 KB
/
Concepts.qll
File metadata and controls
75 lines (65 loc) · 2.54 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/**
* Provides abstract classes representing generic concepts such as file system
* access or system command execution, for which individual framework libraries
* provide concrete subclasses.
*/
overlay[local?]
module;
import java
/**
* A module importing the frameworks that implement `RegexMatch`es,
* ensuring that they are visible to the concepts library.
*/
private module Frameworks {
private import semmle.code.java.JDK
private import semmle.code.java.frameworks.JavaxAnnotations
}
/**
* An expression that represents a regular expression match.
*
* Extend this class to refine existing API models. If you want to model new APIs,
* extend `RegexMatch::Range` instead.
*
* These are either method calls, which return `true` when there is a match, or
* annotations, which are considered to match if they are present.
*/
class RegexMatch extends Expr instanceof RegexMatch::Range {
/** Gets the expression for the regex being executed by this node. */
Expr getRegex() { result = super.getRegex() }
/** Gets an expression for the string to be searched or matched against. */
Expr getString() { result = super.getString() }
/** Gets an expression to be sanitized. */
Expr getASanitizedExpr() { result = [this.getString(), super.getAdditionalSanitizedExpr()] }
/**
* Gets the name of this regex match, typically the name of an executing
* method. This is used for nice alert messages and should include the
* type-qualified name if possible.
*/
string getName() { result = super.getName() }
}
/** Provides classes for modeling regular-expression execution APIs. */
module RegexMatch {
/**
* An expression that executes a regular expression.
*
* Extend this class to model new APIs. If you want to refine existing API models,
* extend `RegexMatch` instead.
*
* These are either method calls, which return `true` when there is a match, or
* annotations, which are considered to match if they are present.
*/
abstract class Range extends Expr {
/** Gets the expression for the regex being executed by this node. */
abstract Expr getRegex();
/** Gets an expression for the string to be searched or matched against. */
abstract Expr getString();
/** Gets an additional expression to be sanitized, if any. */
Expr getAdditionalSanitizedExpr() { none() }
/**
* Gets the name of this regex match, typically the name of an executing
* method. This is used for nice alert messages and should include the
* type-qualified name if possible.
*/
abstract string getName();
}
}