Skip to content

Commit 75b4c30

Browse files
committed
Shared: Make approximate ___location filtering the default behaviour
1 parent 0306ef8 commit 75b4c30

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
@@ -457,15 +457,6 @@ module Configs<LocationSig Location, InputSig<Location> Lang> {
457457
*/
458458
default Location getASelectedSourceLocation(Node source) { result = source.getLocation() }
459459

460-
/**
461-
* Like `getASelectedSourceLocation`, but only has to get a ___location _containing_ the
462-
* actual ___location associated with `source`.
463-
*
464-
* This prunes fewer sources than `getASelectedSourceLocation` but leaves room for the possibility
465-
* that a more precise ___location can be selected in the query.
466-
*/
467-
default Location getASelectedSourceLocationApprox(Node source) { none() }
468-
469460
/**
470461
* Gets a ___location that will be associated with the given `sink` in a
471462
* diff-informed query that uses this configuration (see
@@ -476,15 +467,6 @@ module Configs<LocationSig Location, InputSig<Location> Lang> {
476467
* report the sink at all, this predicate can be `none()`.
477468
*/
478469
default Location getASelectedSinkLocation(Node sink) { result = sink.getLocation() }
479-
480-
/**
481-
* Like `getASelectedSinkLocation`, but only has to get a ___location _containing_ the
482-
* actual ___location associated with `sink`.
483-
*
484-
* This prunes fewer sinks than `getASelectedSinkLocation` but leaves room for the possibility
485-
* that a more precise ___location can be selected in the query.
486-
*/
487-
default Location getASelectedSinkLocationApprox(Node sink) { none() }
488470
}
489471

490472
/** An input configuration for data flow using flow state. */
@@ -624,15 +606,6 @@ module Configs<LocationSig Location, InputSig<Location> Lang> {
624606
*/
625607
default Location getASelectedSourceLocation(Node source) { result = source.getLocation() }
626608

627-
/**
628-
* Like `getASelectedSourceLocation`, but only has to get a ___location _containing_ the
629-
* actual ___location associated with `source`.
630-
*
631-
* This prunes fewer sources than `getASelectedSourceLocation` but leaves room for the possibility
632-
* that a more precise ___location can be selected in the query.
633-
*/
634-
default Location getASelectedSourceLocationApprox(Node source) { none() }
635-
636609
/**
637610
* Gets a ___location that will be associated with the given `sink` in a
638611
* diff-informed query that uses this configuration (see
@@ -643,15 +616,6 @@ module Configs<LocationSig Location, InputSig<Location> Lang> {
643616
* report the sink at all, this predicate can be `none()`.
644617
*/
645618
default Location getASelectedSinkLocation(Node sink) { result = sink.getLocation() }
646-
647-
/**
648-
* Like `getASelectedSinkLocation`, but only has to get a ___location _containing_ the
649-
* actual ___location associated with `sink`.
650-
*
651-
* This prunes fewer sinks than `getASelectedSinkLocation` but leaves room for the possibility
652-
* that a more precise ___location can be selected in the query.
653-
*/
654-
default Location getASelectedSinkLocationApprox(Node sink) { none() }
655619
}
656620
}
657621

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

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

144144
Location getASelectedSourceLocation(Node source);
145145

146-
Location getASelectedSourceLocationApprox(Node source);
147-
148146
Location getASelectedSinkLocation(Node sink);
149-
150-
Location getASelectedSinkLocationApprox(Node sink);
151147
}
152148

153149
/**

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,7 @@ module MakeImplStage1<LocationSig Location, InputSig<Location> Lang> {
131131
private predicate isFilteredSource(Node source) {
132132
Config::isSource(source, _) and
133133
if Config::observeDiffInformedIncrementalMode()
134-
then
135-
AlertFiltering::filterByLocation(Config::getASelectedSourceLocation(source)) or
136-
AlertFiltering::filterByLocationApprox(Config::getASelectedSourceLocationApprox(source))
134+
then AlertFiltering::filterByLocation(Config::getASelectedSourceLocation(source))
137135
else any()
138136
}
139137

@@ -144,9 +142,7 @@ module MakeImplStage1<LocationSig Location, InputSig<Location> Lang> {
144142
Config::isSink(sink)
145143
) and
146144
if Config::observeDiffInformedIncrementalMode()
147-
then
148-
AlertFiltering::filterByLocation(Config::getASelectedSinkLocation(sink)) or
149-
AlertFiltering::filterByLocationApprox(Config::getASelectedSinkLocationApprox(sink))
145+
then AlertFiltering::filterByLocation(Config::getASelectedSinkLocation(sink))
150146
else any()
151147
}
152148

shared/util/codeql/util/AlertFiltering.qll

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

0 commit comments

Comments
 (0)