diff --git a/actions/ql/lib/codeql/actions/security/ArgumentInjectionQuery.qll b/actions/ql/lib/codeql/actions/security/ArgumentInjectionQuery.qll index 1795e9493cb4..7d3334adcf31 100644 --- a/actions/ql/lib/codeql/actions/security/ArgumentInjectionQuery.qll +++ b/actions/ql/lib/codeql/actions/security/ArgumentInjectionQuery.qll @@ -100,8 +100,6 @@ private module ArgumentInjectionConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } - Location getASelectedSourceLocation(DataFlow::Node source) { none() } - Location getASelectedSinkLocation(DataFlow::Node sink) { result = sink.getLocation() or diff --git a/actions/ql/lib/codeql/actions/security/ArtifactPoisoningQuery.qll b/actions/ql/lib/codeql/actions/security/ArtifactPoisoningQuery.qll index 9f3ed33db961..af3b9d62367c 100644 --- a/actions/ql/lib/codeql/actions/security/ArtifactPoisoningQuery.qll +++ b/actions/ql/lib/codeql/actions/security/ArtifactPoisoningQuery.qll @@ -333,8 +333,6 @@ private module ArtifactPoisoningConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } - Location getASelectedSourceLocation(DataFlow::Node source) { none() } - Location getASelectedSinkLocation(DataFlow::Node sink) { result = sink.getLocation() or diff --git a/actions/ql/lib/codeql/actions/security/CodeInjectionQuery.qll b/actions/ql/lib/codeql/actions/security/CodeInjectionQuery.qll index c58e3949a024..0f77acc2444b 100644 --- a/actions/ql/lib/codeql/actions/security/CodeInjectionQuery.qll +++ b/actions/ql/lib/codeql/actions/security/CodeInjectionQuery.qll @@ -80,8 +80,6 @@ private module CodeInjectionConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } - Location getASelectedSourceLocation(DataFlow::Node source) { none() } - Location getASelectedSinkLocation(DataFlow::Node sink) { result = sink.getLocation() or diff --git a/actions/ql/lib/codeql/actions/security/EnvPathInjectionQuery.qll b/actions/ql/lib/codeql/actions/security/EnvPathInjectionQuery.qll index 46c1c4d32006..e97bbbb2b805 100644 --- a/actions/ql/lib/codeql/actions/security/EnvPathInjectionQuery.qll +++ b/actions/ql/lib/codeql/actions/security/EnvPathInjectionQuery.qll @@ -130,8 +130,6 @@ private module EnvPathInjectionConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } - Location getASelectedSourceLocation(DataFlow::Node source) { none() } - Location getASelectedSinkLocation(DataFlow::Node sink) { result = sink.getLocation() or diff --git a/actions/ql/lib/codeql/actions/security/EnvVarInjectionQuery.qll b/actions/ql/lib/codeql/actions/security/EnvVarInjectionQuery.qll index ea8a800ef3f6..40810477d927 100644 --- a/actions/ql/lib/codeql/actions/security/EnvVarInjectionQuery.qll +++ b/actions/ql/lib/codeql/actions/security/EnvVarInjectionQuery.qll @@ -184,8 +184,6 @@ private module EnvVarInjectionConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } - Location getASelectedSourceLocation(DataFlow::Node source) { none() } - Location getASelectedSinkLocation(DataFlow::Node sink) { result = sink.getLocation() or diff --git a/actions/ql/lib/codeql/actions/security/OutputClobberingQuery.qll b/actions/ql/lib/codeql/actions/security/OutputClobberingQuery.qll index 4454a5496a2f..22b4879df126 100644 --- a/actions/ql/lib/codeql/actions/security/OutputClobberingQuery.qll +++ b/actions/ql/lib/codeql/actions/security/OutputClobberingQuery.qll @@ -212,8 +212,6 @@ private module OutputClobberingConfig implements DataFlow::ConfigSig { } predicate observeDiffInformedIncrementalMode() { any() } - - Location getASelectedSourceLocation(DataFlow::Node sink) { none() } } /** Tracks flow of unsafe user input that is used to construct and evaluate an environment variable. */ diff --git a/actions/ql/lib/codeql/actions/security/RequestForgeryQuery.qll b/actions/ql/lib/codeql/actions/security/RequestForgeryQuery.qll index d96a12e2608d..fb89ebdc8baf 100644 --- a/actions/ql/lib/codeql/actions/security/RequestForgeryQuery.qll +++ b/actions/ql/lib/codeql/actions/security/RequestForgeryQuery.qll @@ -18,8 +18,6 @@ private module RequestForgeryConfig implements DataFlow::ConfigSig { predicate isSink(DataFlow::Node sink) { sink instanceof RequestForgerySink } predicate observeDiffInformedIncrementalMode() { any() } - - Location getASelectedSourceLocation(DataFlow::Node sink) { none() } } /** Tracks flow of unsafe user input that is used to construct and evaluate a system command. */ diff --git a/actions/ql/lib/codeql/actions/security/SecretExfiltrationQuery.qll b/actions/ql/lib/codeql/actions/security/SecretExfiltrationQuery.qll index 15cd726c4bba..b3d59210053c 100644 --- a/actions/ql/lib/codeql/actions/security/SecretExfiltrationQuery.qll +++ b/actions/ql/lib/codeql/actions/security/SecretExfiltrationQuery.qll @@ -17,8 +17,6 @@ private module SecretExfiltrationConfig implements DataFlow::ConfigSig { predicate isSink(DataFlow::Node sink) { sink instanceof SecretExfiltrationSink } predicate observeDiffInformedIncrementalMode() { any() } - - Location getASelectedSourceLocation(DataFlow::Node sink) { none() } } /** Tracks flow of unsafe user input that is used in a context where it may lead to a secret exfiltration. */ diff --git a/actions/ql/src/Models/CompositeActionsSinks.ql b/actions/ql/src/Models/CompositeActionsSinks.ql index 65d3fdce9dc7..82f0754f03e2 100644 --- a/actions/ql/src/Models/CompositeActionsSinks.ql +++ b/actions/ql/src/Models/CompositeActionsSinks.ql @@ -26,8 +26,6 @@ private module MyConfig implements DataFlow::ConfigSig { } predicate observeDiffInformedIncrementalMode() { any() } - - Location getASelectedSourceLocation(DataFlow::Node sink) { none() } } module MyFlow = TaintTracking::Global; diff --git a/actions/ql/src/Models/CompositeActionsSources.ql b/actions/ql/src/Models/CompositeActionsSources.ql index 2f3e98b3401e..c9974cd73614 100644 --- a/actions/ql/src/Models/CompositeActionsSources.ql +++ b/actions/ql/src/Models/CompositeActionsSources.ql @@ -36,8 +36,6 @@ private module MyConfig implements DataFlow::ConfigSig { } predicate observeDiffInformedIncrementalMode() { any() } - - Location getASelectedSourceLocation(DataFlow::Node sink) { none() } } module MyFlow = TaintTracking::Global; diff --git a/actions/ql/src/Models/CompositeActionsSummaries.ql b/actions/ql/src/Models/CompositeActionsSummaries.ql index 1979c381f5d6..814498f639e0 100644 --- a/actions/ql/src/Models/CompositeActionsSummaries.ql +++ b/actions/ql/src/Models/CompositeActionsSummaries.ql @@ -27,8 +27,6 @@ private module MyConfig implements DataFlow::ConfigSig { } predicate observeDiffInformedIncrementalMode() { any() } - - Location getASelectedSourceLocation(DataFlow::Node sink) { none() } } module MyFlow = TaintTracking::Global; diff --git a/actions/ql/src/Models/ReusableWorkflowsSinks.ql b/actions/ql/src/Models/ReusableWorkflowsSinks.ql index 2b08f2445d90..8d02debbdb4a 100644 --- a/actions/ql/src/Models/ReusableWorkflowsSinks.ql +++ b/actions/ql/src/Models/ReusableWorkflowsSinks.ql @@ -26,8 +26,6 @@ private module MyConfig implements DataFlow::ConfigSig { } predicate observeDiffInformedIncrementalMode() { any() } - - Location getASelectedSourceLocation(DataFlow::Node sink) { none() } } module MyFlow = TaintTracking::Global; diff --git a/actions/ql/src/Models/ReusableWorkflowsSources.ql b/actions/ql/src/Models/ReusableWorkflowsSources.ql index 831191e4bfb6..a7112bf37584 100644 --- a/actions/ql/src/Models/ReusableWorkflowsSources.ql +++ b/actions/ql/src/Models/ReusableWorkflowsSources.ql @@ -36,8 +36,6 @@ private module MyConfig implements DataFlow::ConfigSig { } predicate observeDiffInformedIncrementalMode() { any() } - - Location getASelectedSourceLocation(DataFlow::Node sink) { none() } } module MyFlow = TaintTracking::Global; diff --git a/actions/ql/src/Models/ReusableWorkflowsSummaries.ql b/actions/ql/src/Models/ReusableWorkflowsSummaries.ql index fd2d4b396a08..a05bec744f84 100644 --- a/actions/ql/src/Models/ReusableWorkflowsSummaries.ql +++ b/actions/ql/src/Models/ReusableWorkflowsSummaries.ql @@ -27,8 +27,6 @@ private module MyConfig implements DataFlow::ConfigSig { } predicate observeDiffInformedIncrementalMode() { any() } - - Location getASelectedSourceLocation(DataFlow::Node sink) { none() } } module MyFlow = TaintTracking::Global; diff --git a/cpp/ql/src/Critical/OverflowDestination.ql b/cpp/ql/src/Critical/OverflowDestination.ql index df14cafd1527..f3f25dfa8223 100644 --- a/cpp/ql/src/Critical/OverflowDestination.ql +++ b/cpp/ql/src/Critical/OverflowDestination.ql @@ -85,10 +85,8 @@ module OverflowDestinationConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } - Location getASelectedSourceLocation(DataFlow::Node source) { none() } - Location getASelectedSinkLocation(DataFlow::Node sink) { - exists(FunctionCall fc | result = fc.getLocation() | + exists(FunctionCall fc | result = [fc.getLocation(), sink.getLocation()] | sourceSized(fc, sink.asIndirectConvertedExpr()) ) } diff --git a/cpp/ql/src/Likely Bugs/Format/NonConstantFormat.ql b/cpp/ql/src/Likely Bugs/Format/NonConstantFormat.ql index 34817ff92295..ed39b8da5cd1 100644 --- a/cpp/ql/src/Likely Bugs/Format/NonConstantFormat.ql +++ b/cpp/ql/src/Likely Bugs/Format/NonConstantFormat.ql @@ -171,12 +171,10 @@ module NonConstFlowConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } - Location getASelectedSourceLocation(DataFlow::Node source) { none() } - Location getASelectedSinkLocation(DataFlow::Node sink) { - result = sink.getLocation() - or - exists(FormattingFunctionCall call, Expr formatString | result = call.getLocation() | + exists(FormattingFunctionCall call, Expr formatString | + result = [call.getLocation(), sink.getLocation()] + | isSinkImpl(sink, formatString) and call.getArgument(call.getFormatParameterIndex()) = formatString ) diff --git a/cpp/ql/src/Security/CWE/CWE-078/ExecTainted.ql b/cpp/ql/src/Security/CWE/CWE-078/ExecTainted.ql index 9119f5271fe6..0e5f0f36f105 100644 --- a/cpp/ql/src/Security/CWE/CWE-078/ExecTainted.ql +++ b/cpp/ql/src/Security/CWE/CWE-078/ExecTainted.ql @@ -155,7 +155,7 @@ module ExecTaintConfig implements DataFlow::StateConfigSig { Location getASelectedSinkLocation(DataFlow::Node sink) { exists(DataFlow::Node concatResult, Expr command, ExecState state | - result = [concatResult.getLocation(), command.getLocation()] and + result = [concatResult.getLocation(), command.getLocation(), sink.getLocation()] and isSink(sink, state) and isSinkImpl(sink, command, _) and concatResult = state.getOutgoingNode() diff --git a/cpp/ql/src/Security/CWE/CWE-089/SqlTainted.ql b/cpp/ql/src/Security/CWE/CWE-089/SqlTainted.ql index 5a823b8672c5..5d08afbe304a 100644 --- a/cpp/ql/src/Security/CWE/CWE-089/SqlTainted.ql +++ b/cpp/ql/src/Security/CWE/CWE-089/SqlTainted.ql @@ -58,7 +58,9 @@ module SqlTaintedConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } Location getASelectedSinkLocation(DataFlow::Node sink) { - exists(Expr taintedArg | result = taintedArg.getLocation() | taintedArg = asSinkExpr(sink)) + exists(Expr taintedArg | result = [taintedArg.getLocation(), sink.getLocation()] | + taintedArg = asSinkExpr(sink) + ) } } diff --git a/cpp/ql/src/Security/CWE/CWE-120/UnboundedWrite.ql b/cpp/ql/src/Security/CWE/CWE-120/UnboundedWrite.ql index ff9bc59b716b..4d33ede93150 100644 --- a/cpp/ql/src/Security/CWE/CWE-120/UnboundedWrite.ql +++ b/cpp/ql/src/Security/CWE/CWE-120/UnboundedWrite.ql @@ -128,7 +128,7 @@ module Config implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } Location getASelectedSinkLocation(DataFlow::Node sink) { - exists(BufferWrite bw | result = bw.getLocation() | isSink(sink, bw, _)) + exists(BufferWrite bw | result = [bw.getLocation(), sink.getLocation()] | isSink(sink, bw, _)) } } diff --git a/cpp/ql/src/Security/CWE/CWE-190/ArithmeticUncontrolled.ql b/cpp/ql/src/Security/CWE/CWE-190/ArithmeticUncontrolled.ql index 64705f078c69..3126573ac5a2 100644 --- a/cpp/ql/src/Security/CWE/CWE-190/ArithmeticUncontrolled.ql +++ b/cpp/ql/src/Security/CWE/CWE-190/ArithmeticUncontrolled.ql @@ -124,7 +124,8 @@ module UncontrolledArithConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } Location getASelectedSourceLocation(DataFlow::Node source) { - result = getExpr(source).getLocation() + isSource(source) and + result = [getExpr(source).getLocation(), source.getLocation()] } } diff --git a/cpp/ql/src/Security/CWE/CWE-190/TaintedAllocationSize.ql b/cpp/ql/src/Security/CWE/CWE-190/TaintedAllocationSize.ql index 0149f483cc12..cf3542ebae5c 100644 --- a/cpp/ql/src/Security/CWE/CWE-190/TaintedAllocationSize.ql +++ b/cpp/ql/src/Security/CWE/CWE-190/TaintedAllocationSize.ql @@ -95,7 +95,7 @@ module TaintedAllocationSizeConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } Location getASelectedSinkLocation(DataFlow::Node sink) { - exists(Expr alloc | result = alloc.getLocation() | allocSink(alloc, sink)) + exists(Expr alloc | result = [alloc.getLocation(), sink.getLocation()] | allocSink(alloc, sink)) } } diff --git a/cpp/ql/src/Security/CWE/CWE-290/AuthenticationBypass.ql b/cpp/ql/src/Security/CWE/CWE-290/AuthenticationBypass.ql index 74386b30bbab..8ee429b8c529 100644 --- a/cpp/ql/src/Security/CWE/CWE-290/AuthenticationBypass.ql +++ b/cpp/ql/src/Security/CWE/CWE-290/AuthenticationBypass.ql @@ -76,7 +76,9 @@ module Config implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } Location getASelectedSinkLocation(DataFlow::Node sink) { - exists(Expr condition | result = condition.getLocation() | isSink(sink, condition)) + exists(Expr condition | result = [condition.getLocation(), sink.getLocation()] | + isSink(sink, condition) + ) } } diff --git a/cpp/ql/src/Security/CWE/CWE-311/CleartextBufferWrite.ql b/cpp/ql/src/Security/CWE/CWE-311/CleartextBufferWrite.ql index c671ad5af7f2..c03c433a532d 100644 --- a/cpp/ql/src/Security/CWE/CWE-311/CleartextBufferWrite.ql +++ b/cpp/ql/src/Security/CWE/CWE-311/CleartextBufferWrite.ql @@ -51,7 +51,9 @@ module ToBufferConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } Location getASelectedSinkLocation(DataFlow::Node sink) { - exists(SensitiveBufferWrite w | result = w.getLocation() | isSinkImpl(sink, w)) + exists(SensitiveBufferWrite w | result = [w.getLocation(), sink.getLocation()] | + isSinkImpl(sink, w) + ) } } diff --git a/cpp/ql/src/Security/CWE/CWE-311/CleartextFileWrite.ql b/cpp/ql/src/Security/CWE/CWE-311/CleartextFileWrite.ql index 6aff19ceb4af..17f4b7ae0fdb 100644 --- a/cpp/ql/src/Security/CWE/CWE-311/CleartextFileWrite.ql +++ b/cpp/ql/src/Security/CWE/CWE-311/CleartextFileWrite.ql @@ -35,11 +35,13 @@ module FromSensitiveConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } Location getASelectedSourceLocation(DataFlow::Node sourceNode) { - exists(SensitiveExpr source | result = source.getLocation() | isSourceImpl(sourceNode, source)) + exists(SensitiveExpr source | result = [source.getLocation(), sourceNode.getLocation()] | + isSourceImpl(sourceNode, source) + ) } Location getASelectedSinkLocation(DataFlow::Node sink) { - exists(FileWrite w | result = w.getLocation() | isSinkImpl(sink, w, _)) + exists(FileWrite w | result = [w.getLocation(), sink.getLocation()] | isSinkImpl(sink, w, _)) } } diff --git a/cpp/ql/src/Security/CWE/CWE-311/CleartextTransmission.ql b/cpp/ql/src/Security/CWE/CWE-311/CleartextTransmission.ql index 10bb10d6a2bb..01d078cf545c 100644 --- a/cpp/ql/src/Security/CWE/CWE-311/CleartextTransmission.ql +++ b/cpp/ql/src/Security/CWE/CWE-311/CleartextTransmission.ql @@ -249,7 +249,9 @@ module FromSensitiveConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } Location getASelectedSinkLocation(DataFlow::Node sink) { - exists(NetworkSendRecv networkSendRecv | result = networkSendRecv.getLocation() | + exists(NetworkSendRecv networkSendRecv | + result = [networkSendRecv.getLocation(), sink.getLocation()] + | isSinkSendRecv(sink, networkSendRecv) ) } diff --git a/cpp/ql/src/Security/CWE/CWE-313/CleartextSqliteDatabase.ql b/cpp/ql/src/Security/CWE/CWE-313/CleartextSqliteDatabase.ql index a6f567600f9d..7cd146e2cace 100644 --- a/cpp/ql/src/Security/CWE/CWE-313/CleartextSqliteDatabase.ql +++ b/cpp/ql/src/Security/CWE/CWE-313/CleartextSqliteDatabase.ql @@ -127,13 +127,13 @@ module FromSensitiveConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } Location getASelectedSourceLocation(DataFlow::Node source) { - exists(SensitiveExpr sensitive | result = sensitive.getLocation() | + exists(SensitiveExpr sensitive | result = [sensitive.getLocation(), source.getLocation()] | isSourceImpl(source, sensitive) ) } Location getASelectedSinkLocation(DataFlow::Node sink) { - exists(SqliteFunctionCall sqliteCall | result = sqliteCall.getLocation() | + exists(SqliteFunctionCall sqliteCall | result = [sqliteCall.getLocation(), sink.getLocation()] | isSinkImpl(sink, sqliteCall, _) ) } diff --git a/cpp/ql/src/Security/CWE/CWE-319/UseOfHttp.ql b/cpp/ql/src/Security/CWE/CWE-319/UseOfHttp.ql index d12340035bde..682d83874333 100644 --- a/cpp/ql/src/Security/CWE/CWE-319/UseOfHttp.ql +++ b/cpp/ql/src/Security/CWE/CWE-319/UseOfHttp.ql @@ -91,10 +91,9 @@ module HttpStringToUrlOpenConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } Location getASelectedSourceLocation(DataFlow::Node source) { - result = source.asIndirectExpr().getLocation() + isSource(source) and + result = [source.asIndirectExpr().getLocation(), source.getLocation()] } - - Location getASelectedSinkLocation(DataFlow::Node sink) { none() } } module HttpStringToUrlOpen = TaintTracking::Global; diff --git a/cpp/ql/src/experimental/Security/CWE/CWE-078/WordexpTainted.ql b/cpp/ql/src/experimental/Security/CWE/CWE-078/WordexpTainted.ql index 1d032a63ba34..cfe04ba23bfa 100644 --- a/cpp/ql/src/experimental/Security/CWE/CWE-078/WordexpTainted.ql +++ b/cpp/ql/src/experimental/Security/CWE/CWE-078/WordexpTainted.ql @@ -50,8 +50,6 @@ module WordexpTaintConfig implements DataFlow::ConfigSig { } predicate observeDiffInformedIncrementalMode() { any() } - - Location getASelectedSourceLocation(DataFlow::Node source) { none() } } module WordexpTaint = TaintTracking::Global; diff --git a/cpp/ql/src/experimental/Security/CWE/CWE-193/ConstantSizeArrayOffByOne.ql b/cpp/ql/src/experimental/Security/CWE/CWE-193/ConstantSizeArrayOffByOne.ql index b7b2de6000ae..58f5dc2ade4b 100644 --- a/cpp/ql/src/experimental/Security/CWE/CWE-193/ConstantSizeArrayOffByOne.ql +++ b/cpp/ql/src/experimental/Security/CWE/CWE-193/ConstantSizeArrayOffByOne.ql @@ -187,12 +187,14 @@ module ArrayAddressToDerefConfig implements DataFlow::StateConfigSig { predicate observeDiffInformedIncrementalMode() { any() } Location getASelectedSourceLocation(DataFlow::Node source) { - exists(Variable v | result = v.getLocation() | isSourceImpl(source, v)) + exists(Variable v | result = v.getLocation() or result = source.getLocation() | + isSourceImpl(source, v) + ) } Location getASelectedSinkLocation(DataFlow::Node sink) { exists(PointerArithmeticInstruction pai, Instruction deref | - result = [pai, deref].getLocation() and + result = [[pai, deref].getLocation(), sink.getLocation()] and isInvalidPointerDerefSink2(sink, deref, _) and isSink(sink, ArrayAddressToDerefConfig::TOverflowArithmetic(pai)) ) diff --git a/cpp/ql/src/experimental/Security/CWE/CWE-409/DecompressionBombs.ql b/cpp/ql/src/experimental/Security/CWE/CWE-409/DecompressionBombs.ql index fbeb4cde5fd1..ec4ba042cb7e 100644 --- a/cpp/ql/src/experimental/Security/CWE/CWE-409/DecompressionBombs.ql +++ b/cpp/ql/src/experimental/Security/CWE/CWE-409/DecompressionBombs.ql @@ -31,8 +31,6 @@ module DecompressionTaintConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } - Location getASelectedSourceLocation(DataFlow::Node source) { none() } - Location getASelectedSinkLocation(DataFlow::Node sink) { exists(FunctionCall fc | result = [sink.getLocation(), fc.getLocation()] | isSink(fc, sink)) } diff --git a/csharp/ql/src/Security Features/CWE-327/DontInstallRootCert.ql b/csharp/ql/src/Security Features/CWE-327/DontInstallRootCert.ql index d2d226716777..b48ddbf0f350 100644 --- a/csharp/ql/src/Security Features/CWE-327/DontInstallRootCert.ql +++ b/csharp/ql/src/Security Features/CWE-327/DontInstallRootCert.ql @@ -39,8 +39,6 @@ module AddCertToRootStoreConfig implements DataFlow::ConfigSig { } predicate observeDiffInformedIncrementalMode() { any() } - - Location getASelectedSourceLocation(DataFlow::Node sink) { none() } } module AddCertToRootStore = DataFlow::Global; diff --git a/go/ql/src/InconsistentCode/UnhandledCloseWritableHandle.ql b/go/ql/src/InconsistentCode/UnhandledCloseWritableHandle.ql index 48e4f98fdb22..25b1c8ae8fc9 100644 --- a/go/ql/src/InconsistentCode/UnhandledCloseWritableHandle.ql +++ b/go/ql/src/InconsistentCode/UnhandledCloseWritableHandle.ql @@ -132,7 +132,7 @@ module UnhandledFileCloseConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } Location getASelectedSourceLocation(DataFlow::Node source) { - exists(DataFlow::CallNode openCall | result = openCall.getLocation() | + exists(DataFlow::CallNode openCall | result = [openCall.getLocation(), source.getLocation()] | isWritableFileHandle(source, openCall) ) } diff --git a/go/ql/src/Security/CWE-326/InsufficientKeySize.ql b/go/ql/src/Security/CWE-326/InsufficientKeySize.ql index 5d0ee7ac6ab3..6fa421baaeb3 100644 --- a/go/ql/src/Security/CWE-326/InsufficientKeySize.ql +++ b/go/ql/src/Security/CWE-326/InsufficientKeySize.ql @@ -27,8 +27,6 @@ module Config implements DataFlow::ConfigSig { } predicate observeDiffInformedIncrementalMode() { any() } - - Location getASelectedSourceLocation(DataFlow::Node sink) { none() } } /** diff --git a/go/ql/src/experimental/CWE-369/DivideByZero.ql b/go/ql/src/experimental/CWE-369/DivideByZero.ql index 8afd165832bc..99cd120dbf8b 100644 --- a/go/ql/src/experimental/CWE-369/DivideByZero.ql +++ b/go/ql/src/experimental/CWE-369/DivideByZero.ql @@ -47,8 +47,6 @@ module Config implements DataFlow::ConfigSig { } predicate observeDiffInformedIncrementalMode() { any() } - - Location getASelectedSourceLocation(DataFlow::Node sink) { none() } } /** diff --git a/go/ql/src/experimental/CWE-918/SSRF.qll b/go/ql/src/experimental/CWE-918/SSRF.qll index f0d3cc935a14..998ce83ba74c 100644 --- a/go/ql/src/experimental/CWE-918/SSRF.qll +++ b/go/ql/src/experimental/CWE-918/SSRF.qll @@ -33,9 +33,9 @@ module ServerSideRequestForgery { predicate observeDiffInformedIncrementalMode() { any() } - Location getASelectedSourceLocation(DataFlow::Node source) { none() } - Location getASelectedSinkLocation(DataFlow::Node sink) { + result = sink.(Sink).getLocation() + or result = sink.(Sink).getARequest().getLocation() } } diff --git a/java/ql/lib/semmle/code/java/security/ArbitraryApkInstallationQuery.qll b/java/ql/lib/semmle/code/java/security/ArbitraryApkInstallationQuery.qll index 8c833bb79d60..e907a9ffeaa8 100644 --- a/java/ql/lib/semmle/code/java/security/ArbitraryApkInstallationQuery.qll +++ b/java/ql/lib/semmle/code/java/security/ArbitraryApkInstallationQuery.qll @@ -25,8 +25,6 @@ module ApkInstallationConfig implements DataFlow::ConfigSig { } predicate observeDiffInformedIncrementalMode() { any() } - - Location getASelectedSourceLocation(DataFlow::Node sink) { none() } } module ApkInstallationFlow = DataFlow::Global; diff --git a/java/ql/lib/semmle/code/java/security/ArithmeticTaintedQuery.qll b/java/ql/lib/semmle/code/java/security/ArithmeticTaintedQuery.qll index fbb8509f48f9..65e73f841495 100644 --- a/java/ql/lib/semmle/code/java/security/ArithmeticTaintedQuery.qll +++ b/java/ql/lib/semmle/code/java/security/ArithmeticTaintedQuery.qll @@ -19,7 +19,9 @@ module ArithmeticOverflowConfig implements DataFlow::ConfigSig { } Location getASelectedSinkLocation(DataFlow::Node sink) { - exists(ArithExpr exp | result = exp.getLocation() | overflowSink(exp, sink.asExpr())) + exists(ArithExpr exp | result = [exp.getLocation(), sink.getLocation()] | + overflowSink(exp, sink.asExpr()) + ) } } @@ -43,7 +45,9 @@ module ArithmeticUnderflowConfig implements DataFlow::ConfigSig { } Location getASelectedSinkLocation(DataFlow::Node sink) { - exists(ArithExpr exp | result = exp.getLocation() | underflowSink(exp, sink.asExpr())) + exists(ArithExpr exp | result = [exp.getLocation(), sink.getLocation()] | + underflowSink(exp, sink.asExpr()) + ) } } diff --git a/java/ql/lib/semmle/code/java/security/ArithmeticUncontrolledQuery.qll b/java/ql/lib/semmle/code/java/security/ArithmeticUncontrolledQuery.qll index 6b7b337ad656..3c1ceaddc2fe 100644 --- a/java/ql/lib/semmle/code/java/security/ArithmeticUncontrolledQuery.qll +++ b/java/ql/lib/semmle/code/java/security/ArithmeticUncontrolledQuery.qll @@ -25,7 +25,9 @@ module ArithmeticUncontrolledOverflowConfig implements DataFlow::ConfigSig { } Location getASelectedSinkLocation(DataFlow::Node sink) { - exists(ArithExpr exp | result = exp.getLocation() | overflowSink(exp, sink.asExpr())) + exists(ArithExpr exp | result = [exp.getLocation(), sink.getLocation()] | + overflowSink(exp, sink.asExpr()) + ) } } @@ -46,7 +48,9 @@ module ArithmeticUncontrolledUnderflowConfig implements DataFlow::ConfigSig { } Location getASelectedSinkLocation(DataFlow::Node sink) { - exists(ArithExpr exp | result = exp.getLocation() | underflowSink(exp, sink.asExpr())) + exists(ArithExpr exp | result = [exp.getLocation(), sink.getLocation()] | + underflowSink(exp, sink.asExpr()) + ) } } diff --git a/java/ql/lib/semmle/code/java/security/BrokenCryptoAlgorithmQuery.qll b/java/ql/lib/semmle/code/java/security/BrokenCryptoAlgorithmQuery.qll index 0c1f14c902b6..60f1e179397c 100644 --- a/java/ql/lib/semmle/code/java/security/BrokenCryptoAlgorithmQuery.qll +++ b/java/ql/lib/semmle/code/java/security/BrokenCryptoAlgorithmQuery.qll @@ -36,7 +36,11 @@ module InsecureCryptoConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } Location getASelectedSinkLocation(DataFlow::Node sink) { - exists(CryptoAlgoSpec c | sink.asExpr() = c.getAlgoSpec() | result = c.getLocation()) + exists(CryptoAlgoSpec c | sink.asExpr() = c.getAlgoSpec() | + result = c.getLocation() + or + result = sink.getLocation() + ) } } diff --git a/java/ql/lib/semmle/code/java/security/CommandLineQuery.qll b/java/ql/lib/semmle/code/java/security/CommandLineQuery.qll index a1c75f93802e..b6b9d02e289d 100644 --- a/java/ql/lib/semmle/code/java/security/CommandLineQuery.qll +++ b/java/ql/lib/semmle/code/java/security/CommandLineQuery.qll @@ -63,10 +63,14 @@ module InputToArgumentToExecFlowConfig implements DataFlow::ConfigSig { // only to prevent overlapping results between two queries. predicate observeDiffInformedIncrementalMode() { any() } - // All queries use the argument as the primary location and do not use the - // sink as an associated location. + // ExecTainted.ql queries use the argument as the primary location; + // ExecUnescaped.ql does not (used to prevent overlapping results). Location getASelectedSinkLocation(DataFlow::Node sink) { - exists(Expr argument | argumentToExec(argument, sink) | result = argument.getLocation()) + exists(Expr argument | argumentToExec(argument, sink) | + result = argument.getLocation() + or + result = sink.getLocation() + ) } } diff --git a/java/ql/lib/semmle/code/java/security/ConditionalBypassQuery.qll b/java/ql/lib/semmle/code/java/security/ConditionalBypassQuery.qll index 314570369377..babf129f19e6 100644 --- a/java/ql/lib/semmle/code/java/security/ConditionalBypassQuery.qll +++ b/java/ql/lib/semmle/code/java/security/ConditionalBypassQuery.qll @@ -51,7 +51,7 @@ module ConditionalBypassFlowConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } Location getASelectedSinkLocation(DataFlow::Node sink) { - exists(MethodCall m, Expr e | result = [m, e].getLocation() | + exists(MethodCall m, Expr e | result = [[m, e].getLocation(), sink.getLocation()] | conditionControlsMethod(m, e) and sink.asExpr() = e ) diff --git a/java/ql/lib/semmle/code/java/security/ImproperValidationOfArrayConstructionCodeSpecifiedQuery.qll b/java/ql/lib/semmle/code/java/security/ImproperValidationOfArrayConstructionCodeSpecifiedQuery.qll index e952971c389f..97a6d159bc94 100644 --- a/java/ql/lib/semmle/code/java/security/ImproperValidationOfArrayConstructionCodeSpecifiedQuery.qll +++ b/java/ql/lib/semmle/code/java/security/ImproperValidationOfArrayConstructionCodeSpecifiedQuery.qll @@ -22,7 +22,10 @@ module BoundedFlowSourceConfig implements DataFlow::ConfigSig { Location getASelectedSinkLocation(DataFlow::Node sink) { exists(ArrayCreationExpr arrayCreation, CheckableArrayAccess arrayAccess | - result = [arrayCreation, arrayAccess.getIndexExpr()].getLocation() and + result = [arrayCreation, arrayAccess.getIndexExpr()].getLocation() + or + result = sink.getLocation() + | arrayAccess.canThrowOutOfBoundsDueToEmptyArray(sink.asExpr(), arrayCreation) ) } diff --git a/java/ql/lib/semmle/code/java/security/ImproperValidationOfArrayConstructionQuery.qll b/java/ql/lib/semmle/code/java/security/ImproperValidationOfArrayConstructionQuery.qll index 913d50b3159d..74b8af7e588f 100644 --- a/java/ql/lib/semmle/code/java/security/ImproperValidationOfArrayConstructionQuery.qll +++ b/java/ql/lib/semmle/code/java/security/ImproperValidationOfArrayConstructionQuery.qll @@ -19,7 +19,10 @@ module ImproperValidationOfArrayConstructionConfig implements DataFlow::ConfigSi Location getASelectedSinkLocation(DataFlow::Node sink) { exists(ArrayCreationExpr arrayCreation, CheckableArrayAccess arrayAccess | - result = [arrayCreation, arrayAccess.getIndexExpr()].getLocation() and + result = [arrayCreation, arrayAccess.getIndexExpr()].getLocation() + or + result = sink.getLocation() + | arrayAccess.canThrowOutOfBoundsDueToEmptyArray(sink.asExpr(), arrayCreation) ) } diff --git a/java/ql/lib/semmle/code/java/security/MaybeBrokenCryptoAlgorithmQuery.qll b/java/ql/lib/semmle/code/java/security/MaybeBrokenCryptoAlgorithmQuery.qll index 57622b367f31..22c7320a55aa 100644 --- a/java/ql/lib/semmle/code/java/security/MaybeBrokenCryptoAlgorithmQuery.qll +++ b/java/ql/lib/semmle/code/java/security/MaybeBrokenCryptoAlgorithmQuery.qll @@ -81,7 +81,9 @@ module InsecureCryptoConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } Location getASelectedSinkLocation(DataFlow::Node sink) { - exists(CryptoAlgoSpec c | result = c.getLocation() | sink.asExpr() = c.getAlgoSpec()) + exists(CryptoAlgoSpec c | result = sink.getLocation() or result = c.getLocation() | + sink.asExpr() = c.getAlgoSpec() + ) } } diff --git a/java/ql/lib/semmle/code/java/security/NumericCastTaintedQuery.qll b/java/ql/lib/semmle/code/java/security/NumericCastTaintedQuery.qll index bfe22c69e642..841ff4f85153 100644 --- a/java/ql/lib/semmle/code/java/security/NumericCastTaintedQuery.qll +++ b/java/ql/lib/semmle/code/java/security/NumericCastTaintedQuery.qll @@ -106,8 +106,9 @@ module NumericCastFlowConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } Location getASelectedSinkLocation(DataFlow::Node sink) { - exists(NumericNarrowingCastExpr cast | - cast.getExpr() = sink.asExpr() and + exists(NumericNarrowingCastExpr cast | cast.getExpr() = sink.asExpr() | + result = sink.getLocation() + or result = cast.getLocation() ) } diff --git a/java/ql/lib/semmle/code/java/security/TaintedEnvironmentVariableQuery.qll b/java/ql/lib/semmle/code/java/security/TaintedEnvironmentVariableQuery.qll index d972b59986a6..2bc9dba92f01 100644 --- a/java/ql/lib/semmle/code/java/security/TaintedEnvironmentVariableQuery.qll +++ b/java/ql/lib/semmle/code/java/security/TaintedEnvironmentVariableQuery.qll @@ -40,8 +40,6 @@ module ExecTaintedEnvironmentConfig implements DataFlow::ConfigSig { } predicate observeDiffInformedIncrementalMode() { any() } - - Location getASelectedSourceLocation(DataFlow::Node source) { none() } } /** diff --git a/java/ql/lib/semmle/code/java/security/TaintedPermissionsCheckQuery.qll b/java/ql/lib/semmle/code/java/security/TaintedPermissionsCheckQuery.qll index bbec7d4f4e6c..7113c7036e4c 100644 --- a/java/ql/lib/semmle/code/java/security/TaintedPermissionsCheckQuery.qll +++ b/java/ql/lib/semmle/code/java/security/TaintedPermissionsCheckQuery.qll @@ -63,8 +63,9 @@ module TaintedPermissionsCheckFlowConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } Location getASelectedSinkLocation(DataFlow::Node sink) { - exists(PermissionsConstruction p | - sink.asExpr() = p.getInput() and + exists(PermissionsConstruction p | sink.asExpr() = p.getInput() | + result = sink.getLocation() + or result = p.getLocation() ) } diff --git a/java/ql/lib/semmle/code/java/security/TempDirLocalInformationDisclosureQuery.qll b/java/ql/lib/semmle/code/java/security/TempDirLocalInformationDisclosureQuery.qll index 098362f2bd53..0ae1d7e4df01 100644 --- a/java/ql/lib/semmle/code/java/security/TempDirLocalInformationDisclosureQuery.qll +++ b/java/ql/lib/semmle/code/java/security/TempDirLocalInformationDisclosureQuery.qll @@ -147,8 +147,6 @@ module TempDirSystemGetPropertyToCreateConfig implements DataFlow::ConfigSig { } predicate observeDiffInformedIncrementalMode() { any() } - - Location getASelectedSinkLocation(DataFlow::Node sink) { none() } } /** diff --git a/java/ql/lib/semmle/code/java/security/UnsafeDeserializationQuery.qll b/java/ql/lib/semmle/code/java/security/UnsafeDeserializationQuery.qll index f5968898adcf..dc771a466063 100644 --- a/java/ql/lib/semmle/code/java/security/UnsafeDeserializationQuery.qll +++ b/java/ql/lib/semmle/code/java/security/UnsafeDeserializationQuery.qll @@ -313,6 +313,8 @@ private module UnsafeDeserializationConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } Location getASelectedSinkLocation(DataFlow::Node sink) { + result = sink.(UnsafeDeserializationSink).getLocation() + or result = sink.(UnsafeDeserializationSink).getMethodCall().getLocation() } } diff --git a/java/ql/lib/semmle/code/java/security/WebviewDebuggingEnabledQuery.qll b/java/ql/lib/semmle/code/java/security/WebviewDebuggingEnabledQuery.qll index 080a7bb482f6..90e47521bf04 100644 --- a/java/ql/lib/semmle/code/java/security/WebviewDebuggingEnabledQuery.qll +++ b/java/ql/lib/semmle/code/java/security/WebviewDebuggingEnabledQuery.qll @@ -46,12 +46,6 @@ module WebviewDebugEnabledConfig implements DataFlow::ConfigSig { } predicate observeDiffInformedIncrementalMode() { any() } - - Location getASelectedSourceLocation(DataFlow::Node source) { - // This module is only used in `WebviewDebuggingEnabled.ql`, which doesn't - // select the source in any "$@" column. - none() - } } /** diff --git a/javascript/ql/lib/semmle/javascript/security/dataflow/CommandInjectionQuery.qll b/javascript/ql/lib/semmle/javascript/security/dataflow/CommandInjectionQuery.qll index 7c013e1f4ace..228f2b8c72c1 100644 --- a/javascript/ql/lib/semmle/javascript/security/dataflow/CommandInjectionQuery.qll +++ b/javascript/ql/lib/semmle/javascript/security/dataflow/CommandInjectionQuery.qll @@ -34,8 +34,9 @@ module CommandInjectionConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } Location getASelectedSinkLocation(DataFlow::Node sink) { - exists(DataFlow::Node node | - isSinkWithHighlight(sink, node) and + exists(DataFlow::Node node | isSinkWithHighlight(sink, node) | + result = sink.getLocation() + or result = node.getLocation() ) } diff --git a/javascript/ql/lib/semmle/javascript/security/dataflow/IndirectCommandInjectionQuery.qll b/javascript/ql/lib/semmle/javascript/security/dataflow/IndirectCommandInjectionQuery.qll index 87d85911a1ba..6dbba8261fbf 100644 --- a/javascript/ql/lib/semmle/javascript/security/dataflow/IndirectCommandInjectionQuery.qll +++ b/javascript/ql/lib/semmle/javascript/security/dataflow/IndirectCommandInjectionQuery.qll @@ -30,8 +30,9 @@ module IndirectCommandInjectionConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } Location getASelectedSinkLocation(DataFlow::Node sink) { - exists(DataFlow::Node node | - isSinkWithHighlight(sink, node) and + exists(DataFlow::Node node | isSinkWithHighlight(sink, node) | + result = sink.getLocation() + or result = node.getLocation() ) } diff --git a/javascript/ql/lib/semmle/javascript/security/dataflow/ShellCommandInjectionFromEnvironmentQuery.qll b/javascript/ql/lib/semmle/javascript/security/dataflow/ShellCommandInjectionFromEnvironmentQuery.qll index 1d396da5b20d..e1dcdd339d9b 100644 --- a/javascript/ql/lib/semmle/javascript/security/dataflow/ShellCommandInjectionFromEnvironmentQuery.qll +++ b/javascript/ql/lib/semmle/javascript/security/dataflow/ShellCommandInjectionFromEnvironmentQuery.qll @@ -33,7 +33,7 @@ module ShellCommandInjectionFromEnvironmentConfig implements DataFlow::ConfigSig Location getASelectedSinkLocation(DataFlow::Node sink) { exists(DataFlow::Node node | isSinkWithHighlight(sink, node) and - result = node.getLocation() + result = [node.getLocation(), sink.getLocation()] ) } } diff --git a/javascript/ql/lib/semmle/javascript/security/regexp/PolynomialReDoSQuery.qll b/javascript/ql/lib/semmle/javascript/security/regexp/PolynomialReDoSQuery.qll index e68fd5af415f..d1baf9c45230 100644 --- a/javascript/ql/lib/semmle/javascript/security/regexp/PolynomialReDoSQuery.qll +++ b/javascript/ql/lib/semmle/javascript/security/regexp/PolynomialReDoSQuery.qll @@ -29,6 +29,8 @@ module PolynomialReDoSConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } Location getASelectedSinkLocation(DataFlow::Node sink) { + result = sink.(Sink).getLocation() + or result = sink.(Sink).getHighlight().getLocation() or result = sink.(Sink).getRegExp().getLocation() diff --git a/javascript/ql/src/experimental/Security/CWE-918/SSRF.qll b/javascript/ql/src/experimental/Security/CWE-918/SSRF.qll index 03bc9f990385..380f594c21e3 100644 --- a/javascript/ql/src/experimental/Security/CWE-918/SSRF.qll +++ b/javascript/ql/src/experimental/Security/CWE-918/SSRF.qll @@ -29,10 +29,6 @@ module SsrfConfig implements DataFlow::ConfigSig { predicate isBarrierOut(DataFlow::Node node) { strictSanitizingPrefixEdge(node, _) } - Location getASelectedSourceLocation(DataFlow::Node source) { - none() // Does not select the source - } - predicate observeDiffInformedIncrementalMode() { any() } } diff --git a/python/ql/lib/semmle/python/security/dataflow/PolynomialReDoSQuery.qll b/python/ql/lib/semmle/python/security/dataflow/PolynomialReDoSQuery.qll index 89aa4961e6ef..11ccf27d7eb3 100644 --- a/python/ql/lib/semmle/python/security/dataflow/PolynomialReDoSQuery.qll +++ b/python/ql/lib/semmle/python/security/dataflow/PolynomialReDoSQuery.qll @@ -21,6 +21,8 @@ private module PolynomialReDoSConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } Location getASelectedSinkLocation(DataFlow::Node sink) { + result = sink.(Sink).getLocation() + or result = sink.(Sink).getHighlight().getLocation() or result = sink.(Sink).getABacktrackingTerm().getLocation() diff --git a/python/ql/lib/semmle/python/security/dataflow/ServerSideRequestForgeryQuery.qll b/python/ql/lib/semmle/python/security/dataflow/ServerSideRequestForgeryQuery.qll index b466d34b2276..e60afa470eca 100644 --- a/python/ql/lib/semmle/python/security/dataflow/ServerSideRequestForgeryQuery.qll +++ b/python/ql/lib/semmle/python/security/dataflow/ServerSideRequestForgeryQuery.qll @@ -68,7 +68,8 @@ private module PartialServerSideRequestForgeryConfig implements DataFlow::Config predicate observeDiffInformedIncrementalMode() { any() } Location getASelectedSinkLocation(DataFlow::Node sink) { - // Note: this query does not select the sink itself + result = sink.(Sink).getLocation() + or result = sink.(Sink).getRequest().getLocation() } } diff --git a/python/ql/src/experimental/Security/CWE-327/Azure/UnsafeUsageOfClientSideEncryptionVersion.ql b/python/ql/src/experimental/Security/CWE-327/Azure/UnsafeUsageOfClientSideEncryptionVersion.ql index a93787c9d790..a0fadbff3f3b 100644 --- a/python/ql/src/experimental/Security/CWE-327/Azure/UnsafeUsageOfClientSideEncryptionVersion.ql +++ b/python/ql/src/experimental/Security/CWE-327/Azure/UnsafeUsageOfClientSideEncryptionVersion.ql @@ -147,8 +147,6 @@ private module AzureBlobClientConfig implements DataFlow::StateConfigSig { } predicate observeDiffInformedIncrementalMode() { any() } - - Location getASelectedSourceLocation(DataFlow::Node sink) { none() } } module AzureBlobClientFlow = DataFlow::GlobalWithState; diff --git a/python/ql/src/experimental/Security/CWE-346/CorsBypass.ql b/python/ql/src/experimental/Security/CWE-346/CorsBypass.ql index 4bb8440c02cd..01e661cb0bbf 100644 --- a/python/ql/src/experimental/Security/CWE-346/CorsBypass.ql +++ b/python/ql/src/experimental/Security/CWE-346/CorsBypass.ql @@ -81,8 +81,6 @@ module CorsBypassConfig implements DataFlow::ConfigSig { } predicate observeDiffInformedIncrementalMode() { any() } - - Location getASelectedSourceLocation(DataFlow::Node sink) { none() } } module CorsFlow = TaintTracking::Global; diff --git a/python/ql/src/experimental/Security/UnsafeUnpackQuery.qll b/python/ql/src/experimental/Security/UnsafeUnpackQuery.qll index 79e50fbd36e9..64da6b8d799a 100644 --- a/python/ql/src/experimental/Security/UnsafeUnpackQuery.qll +++ b/python/ql/src/experimental/Security/UnsafeUnpackQuery.qll @@ -210,8 +210,6 @@ module UnsafeUnpackConfig implements DataFlow::ConfigSig { } predicate observeDiffInformedIncrementalMode() { any() } - - Location getASelectedSourceLocation(DataFlow::Node sink) { none() } } /** Global taint-tracking for detecting "UnsafeUnpacking" vulnerabilities. */ diff --git a/python/ql/src/experimental/semmle/python/security/LdapInsecureAuth.qll b/python/ql/src/experimental/semmle/python/security/LdapInsecureAuth.qll index 431f9f9ab732..630543e6f798 100644 --- a/python/ql/src/experimental/semmle/python/security/LdapInsecureAuth.qll +++ b/python/ql/src/experimental/semmle/python/security/LdapInsecureAuth.qll @@ -103,8 +103,6 @@ private module LdapInsecureAuthConfig implements DataFlow::ConfigSig { } predicate observeDiffInformedIncrementalMode() { any() } - - Location getASelectedSourceLocation(DataFlow::Node sink) { none() } } /** Global taint-tracking for detecting "LDAP insecure authentications" vulnerabilities. */ diff --git a/ruby/ql/lib/codeql/ruby/security/regexp/PolynomialReDoSQuery.qll b/ruby/ql/lib/codeql/ruby/security/regexp/PolynomialReDoSQuery.qll index 81179717e01e..7ff627714624 100644 --- a/ruby/ql/lib/codeql/ruby/security/regexp/PolynomialReDoSQuery.qll +++ b/ruby/ql/lib/codeql/ruby/security/regexp/PolynomialReDoSQuery.qll @@ -24,6 +24,8 @@ private module PolynomialReDoSConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { none() } Location getASelectedSinkLocation(DataFlow::Node sink) { + result = sink.(Sink).getLocation() + or result = sink.(Sink).getHighlight().getLocation() or result = sink.(Sink).getRegExp().getRootTerm().getLocation() diff --git a/ruby/ql/src/experimental/manually-check-http-verb/ManuallyCheckHttpVerb.ql b/ruby/ql/src/experimental/manually-check-http-verb/ManuallyCheckHttpVerb.ql index 80113ee78232..4af2425b1a82 100644 --- a/ruby/ql/src/experimental/manually-check-http-verb/ManuallyCheckHttpVerb.ql +++ b/ruby/ql/src/experimental/manually-check-http-verb/ManuallyCheckHttpVerb.ql @@ -88,8 +88,6 @@ private module HttpVerbConfig implements DataFlow::ConfigSig { } predicate observeDiffInformedIncrementalMode() { any() } - - Location getASelectedSourceLocation(DataFlow::Node source) { none() } } private module HttpVerbFlow = TaintTracking::Global; diff --git a/ruby/ql/src/experimental/weak-params/WeakParams.ql b/ruby/ql/src/experimental/weak-params/WeakParams.ql index 2abc151a9201..faec728a2dd8 100644 --- a/ruby/ql/src/experimental/weak-params/WeakParams.ql +++ b/ruby/ql/src/experimental/weak-params/WeakParams.ql @@ -48,8 +48,6 @@ private module WeakParamsConfig implements DataFlow::ConfigSig { predicate isSink(DataFlow::Node node) { node = any(PersistentWriteAccess a).getValue() } predicate observeDiffInformedIncrementalMode() { any() } - - Location getASelectedSourceLocation(DataFlow::Node source) { none() } } private module WeakParamsFlow = TaintTracking::Global; diff --git a/ruby/ql/src/queries/security/cwe-732/WeakFilePermissions.ql b/ruby/ql/src/queries/security/cwe-732/WeakFilePermissions.ql index dbc5db91d998..eef9f9e8f8dc 100644 --- a/ruby/ql/src/queries/security/cwe-732/WeakFilePermissions.ql +++ b/ruby/ql/src/queries/security/cwe-732/WeakFilePermissions.ql @@ -60,8 +60,9 @@ private module PermissivePermissionsConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } Location getASelectedSinkLocation(DataFlow::Node sink) { - exists(FileSystemPermissionModification mod | - sinkDef(sink, mod) and + exists(FileSystemPermissionModification mod | sinkDef(sink, mod) | + result = sink.getLocation() + or result = mod.getLocation() ) } diff --git a/rust/ql/src/queries/security/CWE-614/InsecureCookie.ql b/rust/ql/src/queries/security/CWE-614/InsecureCookie.ql index e2d7288db45b..3fb4924470fe 100644 --- a/rust/ql/src/queries/security/CWE-614/InsecureCookie.ql +++ b/rust/ql/src/queries/security/CWE-614/InsecureCookie.ql @@ -74,7 +74,9 @@ module PartitionedCookieConfig implements DataFlow::ConfigSig { node instanceof Barrier } - predicate observeDiffInformedIncrementalMode() { any() } + predicate observeDiffInformedIncrementalMode() { + none() // only used negatively + } } module InsecureCookieFlow = TaintTracking::Global; diff --git a/rust/ql/src/queries/security/CWE-825/AccessAfterLifetime.ql b/rust/ql/src/queries/security/CWE-825/AccessAfterLifetime.ql index fce64dcf0ff1..65c6d8616381 100644 --- a/rust/ql/src/queries/security/CWE-825/AccessAfterLifetime.ql +++ b/rust/ql/src/queries/security/CWE-825/AccessAfterLifetime.ql @@ -32,7 +32,9 @@ module AccessAfterLifetimeConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } Location getASelectedSourceLocation(DataFlow::Node source) { - exists(Variable target, DataFlow::Node sink | result = target.getLocation() | + exists(Variable target, DataFlow::Node sink | + result = [target.getLocation(), source.getLocation()] + | isSink(sink) and narrowDereferenceAfterLifetime(source, sink, target) ) diff --git a/shared/dataflow/codeql/dataflow/DataFlow.qll b/shared/dataflow/codeql/dataflow/DataFlow.qll index 49f84d45b2ad..7f9c0194374b 100644 --- a/shared/dataflow/codeql/dataflow/DataFlow.qll +++ b/shared/dataflow/codeql/dataflow/DataFlow.qll @@ -466,8 +466,10 @@ module Configs Lang> { * `observeDiffInformedIncrementalMode`). By default, this is the location * of the source itself, but this predicate should include any locations * that are reported as the primary-location of the query or as an - * additional location ("$@" interpolation). For a query that doesn't - * report the source at all, this predicate can be `none()`. + * additional location ("$@" interpolation). Queries with `@kind path-problem` + * that override this predicate should also return the location of the source + * itself. For a query that doesn't report the source at all, this predicate + * should be `none()`. */ default Location getASelectedSourceLocation(Node source) { result = source.getLocation() } @@ -477,8 +479,10 @@ module Configs Lang> { * `observeDiffInformedIncrementalMode`). By default, this is the location * of the sink itself, but this predicate should include any locations * that are reported as the primary-location of the query or as an - * additional location ("$@" interpolation). For a query that doesn't - * report the sink at all, this predicate can be `none()`. + * additional location ("$@" interpolation). Queries with `@kind path-problem` + * that override this predicate should also return the location of the sink + * itself. For a query that doesn't report the sink at all, this predicate + * should be `none()`. */ default Location getASelectedSinkLocation(Node sink) { result = sink.getLocation() } } @@ -615,8 +619,10 @@ module Configs Lang> { * `observeDiffInformedIncrementalMode`). By default, this is the location * of the source itself, but this predicate should include any locations * that are reported as the primary-location of the query or as an - * additional location ("$@" interpolation). For a query that doesn't - * report the source at all, this predicate can be `none()`. + * additional location ("$@" interpolation). Queries with `@kind path-problem` + * that override this predicate should also return the location of the source + * itself. For a query that doesn't report the source at all, this predicate + * should be `none()`. */ default Location getASelectedSourceLocation(Node source) { result = source.getLocation() } @@ -626,8 +632,10 @@ module Configs Lang> { * `observeDiffInformedIncrementalMode`). By default, this is the location * of the sink itself, but this predicate should include any locations * that are reported as the primary-location of the query or as an - * additional location ("$@" interpolation). For a query that doesn't - * report the sink at all, this predicate can be `none()`. + * additional location ("$@" interpolation). Queries with `@kind path-problem` + * that override this predicate should also return the location of the sink + * itself. For a query that doesn't report the sink at all, this predicate + * should be `none()`. */ default Location getASelectedSinkLocation(Node sink) { result = sink.getLocation() } } diff --git a/swift/ql/lib/codeql/swift/security/CleartextStorageDatabaseQuery.qll b/swift/ql/lib/codeql/swift/security/CleartextStorageDatabaseQuery.qll index 989d928a8c71..50a421a05dc4 100644 --- a/swift/ql/lib/codeql/swift/security/CleartextStorageDatabaseQuery.qll +++ b/swift/ql/lib/codeql/swift/security/CleartextStorageDatabaseQuery.qll @@ -52,12 +52,13 @@ module CleartextStorageDatabaseConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } Location getASelectedSinkLocation(DataFlow::Node sink) { - exists(DataFlow::Node cleanSink | result = cleanSink.getLocation() | - cleanSink = sink.(DataFlow::PostUpdateNode).getPreUpdateNode() - or - not sink instanceof DataFlow::PostUpdateNode and - cleanSink = sink - ) + result = sink.(CleartextStorageDatabaseSink).getLocation() + or + result = + sink.(CleartextStorageDatabaseSink) + .(DataFlow::PostUpdateNode) + .getPreUpdateNode() + .getLocation() } } diff --git a/swift/ql/lib/codeql/swift/security/CleartextStoragePreferencesQuery.qll b/swift/ql/lib/codeql/swift/security/CleartextStoragePreferencesQuery.qll index c3665589482a..578fe0b36e0a 100644 --- a/swift/ql/lib/codeql/swift/security/CleartextStoragePreferencesQuery.qll +++ b/swift/ql/lib/codeql/swift/security/CleartextStoragePreferencesQuery.qll @@ -34,12 +34,13 @@ module CleartextStoragePreferencesConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } Location getASelectedSinkLocation(DataFlow::Node sink) { - exists(DataFlow::Node cleanSink | result = cleanSink.getLocation() | - cleanSink = sink.(DataFlow::PostUpdateNode).getPreUpdateNode() - or - not sink instanceof DataFlow::PostUpdateNode and - cleanSink = sink - ) + result = sink.(CleartextStoragePreferencesSink).getLocation() + or + result = + sink.(CleartextStoragePreferencesSink) + .(DataFlow::PostUpdateNode) + .getPreUpdateNode() + .getLocation() } } diff --git a/swift/ql/lib/codeql/swift/security/ConstantPasswordQuery.qll b/swift/ql/lib/codeql/swift/security/ConstantPasswordQuery.qll index c0d4d7cd8963..91d46b764df5 100644 --- a/swift/ql/lib/codeql/swift/security/ConstantPasswordQuery.qll +++ b/swift/ql/lib/codeql/swift/security/ConstantPasswordQuery.qll @@ -40,8 +40,6 @@ module ConstantPasswordConfig implements DataFlow::ConfigSig { } predicate observeDiffInformedIncrementalMode() { any() } - - Location getASelectedSourceLocation(DataFlow::Node sink) { none() } } module ConstantPasswordFlow = TaintTracking::Global; diff --git a/swift/ql/lib/codeql/swift/security/InsufficientHashIterationsQuery.qll b/swift/ql/lib/codeql/swift/security/InsufficientHashIterationsQuery.qll index f1f21dabe034..0a7fea3d3c53 100644 --- a/swift/ql/lib/codeql/swift/security/InsufficientHashIterationsQuery.qll +++ b/swift/ql/lib/codeql/swift/security/InsufficientHashIterationsQuery.qll @@ -36,8 +36,6 @@ module InsufficientHashIterationsConfig implements DataFlow::ConfigSig { } predicate observeDiffInformedIncrementalMode() { any() } - - Location getASelectedSourceLocation(DataFlow::Node sink) { none() } } module InsufficientHashIterationsFlow = TaintTracking::Global; diff --git a/swift/ql/lib/codeql/swift/security/StaticInitializationVectorQuery.qll b/swift/ql/lib/codeql/swift/security/StaticInitializationVectorQuery.qll index fb6e21cac52d..3c4359e02db0 100644 --- a/swift/ql/lib/codeql/swift/security/StaticInitializationVectorQuery.qll +++ b/swift/ql/lib/codeql/swift/security/StaticInitializationVectorQuery.qll @@ -42,8 +42,6 @@ module StaticInitializationVectorConfig implements DataFlow::ConfigSig { } predicate observeDiffInformedIncrementalMode() { any() } - - Location getASelectedSourceLocation(DataFlow::Node sink) { none() } } module StaticInitializationVectorFlow = TaintTracking::Global; diff --git a/swift/ql/lib/codeql/swift/security/StringLengthConflationQuery.qll b/swift/ql/lib/codeql/swift/security/StringLengthConflationQuery.qll index 5ddcd2333e28..eb17306f22f0 100644 --- a/swift/ql/lib/codeql/swift/security/StringLengthConflationQuery.qll +++ b/swift/ql/lib/codeql/swift/security/StringLengthConflationQuery.qll @@ -41,8 +41,6 @@ module StringLengthConflationConfig implements DataFlow::StateConfigSig { } predicate observeDiffInformedIncrementalMode() { any() } - - Location getASelectedSourceLocation(DataFlow::Node sink) { none() } } /** diff --git a/swift/ql/lib/codeql/swift/security/UnsafeJsEvalQuery.qll b/swift/ql/lib/codeql/swift/security/UnsafeJsEvalQuery.qll index e82db8f4e7bf..92b061b2af40 100644 --- a/swift/ql/lib/codeql/swift/security/UnsafeJsEvalQuery.qll +++ b/swift/ql/lib/codeql/swift/security/UnsafeJsEvalQuery.qll @@ -24,8 +24,6 @@ module UnsafeJsEvalConfig implements DataFlow::ConfigSig { } predicate observeDiffInformedIncrementalMode() { any() } - - Location getASelectedSourceLocation(DataFlow::Node sink) { none() } } /** diff --git a/swift/ql/lib/codeql/swift/security/UnsafeUnpackQuery.qll b/swift/ql/lib/codeql/swift/security/UnsafeUnpackQuery.qll index a8485ff99471..e79bce5ba143 100644 --- a/swift/ql/lib/codeql/swift/security/UnsafeUnpackQuery.qll +++ b/swift/ql/lib/codeql/swift/security/UnsafeUnpackQuery.qll @@ -26,8 +26,6 @@ module UnsafeUnpackConfig implements DataFlow::ConfigSig { } predicate observeDiffInformedIncrementalMode() { any() } - - Location getASelectedSourceLocation(DataFlow::Node sink) { none() } } /**