Skip to content

Commit 4a2d795

Browse files
committed
Shared: Make approximate location filtering the default behaviour
1 parent 82d190f commit 4a2d795

File tree

7 files changed

+5
-85
lines changed

7 files changed

+5
-85
lines changed

java/ql/lib/semmle/code/java/security/regexp/PolynomialReDoSQuery.qll

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,7 @@ module PolynomialRedosConfig implements DataFlow::ConfigSig {
5555
regexp.getRootTerm() = sink.(PolynomialRedosSink).getRegExp()
5656
|
5757
result = sink.getLocation()
58-
)
59-
}
60-
61-
Location getASelectedSinkLocationApprox(DataFlow::Node sink) {
62-
exists(SuperlinearBackTracking::PolynomialBackTrackingTerm regexp |
63-
regexp.getRootTerm() = sink.(PolynomialRedosSink).getRegExp()
64-
|
58+
or
6559
result = regexp.getLocation()
6660
)
6761
}

python/ql/lib/semmle/python/security/dataflow/PolynomialReDoSQuery.qll

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ private module PolynomialReDoSConfig implements DataFlow::ConfigSig {
2222

2323
Location getASelectedSinkLocation(DataFlow::Node sink) {
2424
result = sink.(Sink).getHighlight().getLocation()
25-
}
26-
27-
Location getASelectedSinkLocationApprox(DataFlow::Node sink) {
25+
or
2826
result = sink.(Sink).getABacktrackingTerm().getLocation()
2927
}
3028
}

ruby/ql/lib/codeql/ruby/security/regexp/PolynomialReDoSQuery.qll

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ private module PolynomialReDoSConfig implements DataFlow::ConfigSig {
2525

2626
Location getASelectedSinkLocation(DataFlow::Node sink) {
2727
result = sink.(Sink).getHighlight().getLocation()
28-
}
29-
30-
Location getASelectedSinkLocationApprox(DataFlow::Node sink) {
28+
or
3129
result = sink.(Sink).getRegExp().getRootTerm().getLocation()
3230
}
3331
}

shared/dataflow/codeql/dataflow/DataFlow.qll

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -459,15 +459,6 @@ module Configs<LocationSig Location, InputSig<Location> Lang> {
459459
*/
460460
default Location getASelectedSourceLocation(Node source) { result = source.getLocation() }
461461

462-
/**
463-
* Like `getASelectedSourceLocation`, but only has to get a location _containing_ the
464-
* actual location associated with `source`.
465-
*
466-
* This prunes fewer sources than `getASelectedSourceLocation` but leaves room for the possibility
467-
* that a more precise location can be selected in the query.
468-
*/
469-
default Location getASelectedSourceLocationApprox(Node source) { none() }
470-
471462
/**
472463
* Gets a location that will be associated with the given `sink` in a
473464
* diff-informed query that uses this configuration (see
@@ -478,15 +469,6 @@ module Configs<LocationSig Location, InputSig<Location> Lang> {
478469
* report the sink at all, this predicate can be `none()`.
479470
*/
480471
default Location getASelectedSinkLocation(Node sink) { result = sink.getLocation() }
481-
482-
/**
483-
* Like `getASelectedSinkLocation`, but only has to get a location _containing_ the
484-
* actual location associated with `sink`.
485-
*
486-
* This prunes fewer sinks than `getASelectedSinkLocation` but leaves room for the possibility
487-
* that a more precise location can be selected in the query.
488-
*/
489-
default Location getASelectedSinkLocationApprox(Node sink) { none() }
490472
}
491473

492474
/** An input configuration for data flow using flow state. */
@@ -626,15 +608,6 @@ module Configs<LocationSig Location, InputSig<Location> Lang> {
626608
*/
627609
default Location getASelectedSourceLocation(Node source) { result = source.getLocation() }
628610

629-
/**
630-
* Like `getASelectedSourceLocation`, but only has to get a location _containing_ the
631-
* actual location associated with `source`.
632-
*
633-
* This prunes fewer sources than `getASelectedSourceLocation` but leaves room for the possibility
634-
* that a more precise location can be selected in the query.
635-
*/
636-
default Location getASelectedSourceLocationApprox(Node source) { none() }
637-
638611
/**
639612
* Gets a location that will be associated with the given `sink` in a
640613
* diff-informed query that uses this configuration (see
@@ -645,15 +618,6 @@ module Configs<LocationSig Location, InputSig<Location> Lang> {
645618
* report the sink at all, this predicate can be `none()`.
646619
*/
647620
default Location getASelectedSinkLocation(Node sink) { result = sink.getLocation() }
648-
649-
/**
650-
* Like `getASelectedSinkLocation`, but only has to get a location _containing_ the
651-
* actual location associated with `sink`.
652-
*
653-
* This prunes fewer sinks than `getASelectedSinkLocation` but leaves room for the possibility
654-
* that a more precise location can be selected in the query.
655-
*/
656-
default Location getASelectedSinkLocationApprox(Node sink) { none() }
657621
}
658622
}
659623

shared/dataflow/codeql/dataflow/internal/DataFlowImpl.qll

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,7 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
145145

146146
Location getASelectedSourceLocation(Node source);
147147

148-
Location getASelectedSourceLocationApprox(Node source);
149-
150148
Location getASelectedSinkLocation(Node sink);
151-
152-
Location getASelectedSinkLocationApprox(Node sink);
153149
}
154150

155151
/**

shared/dataflow/codeql/dataflow/internal/DataFlowImplStage1.qll

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,7 @@ module MakeImplStage1<LocationSig Location, InputSig<Location> Lang> {
133133
private predicate isFilteredSource(Node source) {
134134
Config::isSource(source, _) and
135135
if Config::observeDiffInformedIncrementalMode()
136-
then
137-
AlertFiltering::filterByLocation(Config::getASelectedSourceLocation(source)) or
138-
AlertFiltering::filterByLocationApprox(Config::getASelectedSourceLocationApprox(source))
136+
then AlertFiltering::filterByLocation(Config::getASelectedSourceLocation(source))
139137
else any()
140138
}
141139

@@ -146,9 +144,7 @@ module MakeImplStage1<LocationSig Location, InputSig<Location> Lang> {
146144
Config::isSink(sink)
147145
) and
148146
if Config::observeDiffInformedIncrementalMode()
149-
then
150-
AlertFiltering::filterByLocation(Config::getASelectedSinkLocation(sink)) or
151-
AlertFiltering::filterByLocationApprox(Config::getASelectedSinkLocationApprox(sink))
147+
then AlertFiltering::filterByLocation(Config::getASelectedSinkLocation(sink))
152148
else any()
153149
}
154150

shared/util/codeql/util/AlertFiltering.qll

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -89,32 +89,6 @@ module AlertFilteringImpl<LocationSig Location> {
8989
/** Applies alert filtering to the given location. */
9090
bindingset[location]
9191
predicate filterByLocation(Location location) {
92-
not restrictAlertsTo(_, _, _) and not restrictAlertsToExactLocation(_, _, _, _, _)
93-
or
94-
exists(string filePath |
95-
restrictAlertsToEntireFile(filePath) and
96-
location.hasLocationInfo(filePath, _, _, _, _)
97-
or
98-
exists(int line |
99-
restrictAlertsToStartLine(filePath, line) and
100-
location.hasLocationInfo(filePath, line, _, _, _)
101-
)
102-
)
103-
or
104-
exists(string filePath, int startLine, int startColumn, int endLine, int endColumn |
105-
restrictAlertsToExactLocation(filePath, startLine, startColumn, endLine, endColumn)
106-
|
107-
location.hasLocationInfo(filePath, startLine, startColumn, endLine, endColumn)
108-
)
109-
}
110-
111-
/**
112-
* Holds if some subrange within `location` would be accepted by alert filtering.
113-
*
114-
* There does not need to exist a `Location` corresponding to that subrange.
115-
*/
116-
bindingset[location]
117-
predicate filterByLocationApprox(Location location) {
11892
not restrictAlertsTo(_, _, _) and not restrictAlertsToExactLocation(_, _, _, _, _)
11993
or
12094
exists(string filePath |

0 commit comments

Comments
 (0)