| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1a95a34 commit 551b34e
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -55,7 +55,7 @@ private Endpoint getSampleForSignature( | |||
| 55 | 55 | from | |
| 56 | 56 | Endpoint endpoint, string message, ApplicationModeMetadataExtractor meta, DollarAtString package, | |
| 57 | 57 | DollarAtString type, DollarAtString subtypes, DollarAtString name, DollarAtString signature, | |
| 58 | - DollarAtString input, DollarAtString isVarargsArray | ||
| 58 | + DollarAtString input, DollarAtString isVarargsArray, DollarAtString alreadyAiModeled | ||
| 59 | 59 | where | |
| 60 | 60 | not exists(CharacteristicsImpl::UninterestingToModelCharacteristic u | | |
| 61 | 61 | u.appliesToEndpoint(endpoint) | |
@@ -67,25 +67,31 @@ where | |||
| 67 | 67 | // label it as a sink for one of the sink types of query B, for which it's already a known sink. This would result in | |
| 68 | 68 | // overlap between our detected sinks and the pre-existing modeling. We assume that, if a sink has already been | |
| 69 | 69 | // modeled in a MaD model, then it doesn't belong to any additional sink types, and we don't need to reexamine it. | |
| 70 | - not CharacteristicsImpl::isSink(endpoint, _, _) and | ||
| 70 | + ( | ||
| 71 | + not CharacteristicsImpl::isSink(endpoint, _, _) and alreadyAiModeled = "false" | ||
| 72 | + or | ||
| 73 | + CharacteristicsImpl::isSink(endpoint, _, any(string s | s.matches("%ai-%"))) and | ||
| 74 | + alreadyAiModeled = "true" | ||
| 75 | + ) and | ||
| 71 | 76 | meta.hasMetadata(endpoint, package, type, subtypes, name, signature, input, isVarargsArray) and | |
| 72 | 77 | includeAutomodelCandidate(package, type, name, signature) and | |
| 73 | 78 | // The message is the concatenation of all sink types for which this endpoint is known neither to be a sink nor to be | |
| 74 | 79 | // a non-sink, and we surface only endpoints that have at least one such sink type. | |
| 75 | 80 | message = | |
| 76 | 81 | strictconcat(AutomodelEndpointTypes::SinkType sinkType | | |
| 77 | - not CharacteristicsImpl::isKnownSink(endpoint, sinkType) and | ||
| 82 | + not CharacteristicsImpl::isKnownSink(endpoint, sinkType, _) and | ||
| 78 | 83 | CharacteristicsImpl::isSinkCandidate(endpoint, sinkType) | |
| 79 | 84 | | | |
| 80 | 85 | sinkType, ", " | |
| 81 | 86 | ) | |
| 82 | 87 | select endpoint.asNode(), | |
| 83 | - message + "\nrelated locations: $@." + "\nmetadata: $@, $@, $@, $@, $@, $@, $@.", // | ||
| 88 | + message + "\nrelated locations: $@." + "\nmetadata: $@, $@, $@, $@, $@, $@, $@, $@.", // | ||
| 84 | 89 | CharacteristicsImpl::getRelatedLocationOrCandidate(endpoint, CallContext()), "CallContext", // | |
| 85 | 90 | package, "package", // | |
| 86 | 91 | type, "type", // | |
| 87 | 92 | subtypes, "subtypes", // | |
| 88 | 93 | name, "name", // method name | |
| 89 | 94 | signature, "signature", // | |
| 90 | 95 | input, "input", // | |
| 91 | - isVarargsArray, "isVarargsArray" | ||
| 96 | + isVarargsArray, "isVarargsArray", // | ||
| 97 | + alreadyAiModeled, "alreadyAiModeled" | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,7 +22,7 @@ where | |||
| 22 | 22 | not erroneousEndpoints(endpoint, _, _, _, _, false) and | |
| 23 | 23 | meta.hasMetadata(endpoint, package, type, subtypes, name, signature, input, isVarargsArray) and | |
| 24 | 24 | // Extract positive examples of sinks belonging to the existing ATM query configurations. | |
| 25 | - CharacteristicsImpl::isKnownSink(endpoint, sinkType) and | ||
| 25 | + CharacteristicsImpl::isKnownSink(endpoint, sinkType, _) and | ||
| 26 | 26 | exists(CharacteristicsImpl::getRelatedLocationOrCandidate(endpoint, CallContext())) | |
| 27 | 27 | select endpoint.asNode(), | |
| 28 | 28 | sinkType + "\nrelated locations: $@." + "\nmetadata: $@, $@, $@, $@, $@, $@, $@.", // | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -94,14 +94,15 @@ module SharedCharacteristics<CandidateSig Candidate> { | |||
| 94 | 94 | /** | |
| 95 | 95 | * Holds if `sink` is a known sink of type `endpointType`. | |
| 96 | 96 | */ | |
| 97 | - predicate isKnownSink(Candidate::Endpoint sink, Candidate::EndpointType endpointType) { | ||
| 97 | + predicate isKnownSink( | ||
| 98 | + Candidate::Endpoint sink, Candidate::EndpointType endpointType, | ||
| 99 | + EndpointCharacteristic characteristic | ||
| 100 | + ) { | ||
| 98 | 101 | // If the list of characteristics includes positive indicators with maximal confidence for this class, then it's a | |
| 99 | 102 | // known sink for the class. | |
| 100 | 103 | not endpointType instanceof Candidate::NegativeEndpointType and | |
| 101 | - exists(EndpointCharacteristic characteristic | | ||
| 102 | - characteristic.appliesToEndpoint(sink) and | ||
| 103 | - characteristic.hasImplications(endpointType, true, maximalConfidence()) | ||
| 104 | - ) | ||
| 104 | + characteristic.appliesToEndpoint(sink) and | ||
| 105 | + characteristic.hasImplications(endpointType, true, maximalConfidence()) | ||
| 105 | 106 | } | |
| 106 | 107 | ||
| 107 | 108 | /** | |
@@ -275,15 +276,17 @@ module SharedCharacteristics<CandidateSig Candidate> { | |||
| 275 | 276 | private class KnownSinkCharacteristic extends SinkCharacteristic { | |
| 276 | 277 | string madKind; | |
| 277 | 278 | Candidate::EndpointType endpointType; | |
| 279 | + string provenance; | ||
| 278 | 280 | ||
| 279 | 281 | KnownSinkCharacteristic() { | |
| 280 | 282 | Candidate::isKnownKind(madKind, endpointType) and | |
| 281 | 283 | // bind "this" to a unique string differing from that of the SinkType classes | |
| 282 | - this = madKind + "-characteristic" | ||
| 284 | + this = madKind + "_" + provenance + "_characteristic" and | ||
| 285 | + Candidate::isSink(_, madKind, provenance) | ||
| 283 | 286 | } | |
| 284 | 287 | ||
| 285 | 288 | override predicate appliesToEndpoint(Candidate::Endpoint e) { | |
| 286 | - Candidate::isSink(e, madKind, _) | ||
| 289 | + Candidate::isSink(e, madKind, provenance) | ||
| 287 | 290 | } | |
| 288 | 291 | ||
| 289 | 292 | override Candidate::EndpointType getSinkType() { result = endpointType } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,4 @@ | |||
| 1 | - | Test.java:16:3:16:11 | reference | command-injection, path-injection, request-forgery, sql-injection\nrelated locations: $@.\nmetadata: $@, $@, $@, $@, $@, $@, $@. | Test.java:16:3:16:24 | set(...) | CallContext | file://java.util.concurrent.atomic:1:1:1:1 | java.util.concurrent.atomic | package | file://AtomicReference:1:1:1:1 | AtomicReference | type | file://false:1:1:1:1 | false | subtypes | file://set:1:1:1:1 | set | name | file://(String):1:1:1:1 | (String) | signature | file://Argument[this]:1:1:1:1 | Argument[this] | input | file://false:1:1:1:1 | false | isVarargsArray | | ||
| 2 | - | Test.java:21:3:21:10 | supplier | command-injection, path-injection, request-forgery, sql-injection\nrelated locations: $@.\nmetadata: $@, $@, $@, $@, $@, $@, $@. | Test.java:21:3:21:16 | get(...) | CallContext | file://java.util.function:1:1:1:1 | java.util.function | package | file://Supplier:1:1:1:1 | Supplier | type | file://true:1:1:1:1 | true | subtypes | file://get:1:1:1:1 | get | name | file://():1:1:1:1 | () | signature | file://Argument[this]:1:1:1:1 | Argument[this] | input | file://false:1:1:1:1 | false | isVarargsArray | | ||
| 3 | - | Test.java:53:4:53:4 | o | command-injection, path-injection, request-forgery, sql-injection\nrelated locations: $@.\nmetadata: $@, $@, $@, $@, $@, $@, $@. | Test.java:51:3:56:3 | walk(...) | CallContext | file://java.nio.file:1:1:1:1 | java.nio.file | package | file://Files:1:1:1:1 | Files | type | file://false:1:1:1:1 | false | subtypes | file://walk:1:1:1:1 | walk | name | file://(Path,FileVisitOption[]):1:1:1:1 | (Path,FileVisitOption[]) | signature | file://Argument[1]:1:1:1:1 | Argument[1] | input | file://true:1:1:1:1 | true | isVarargsArray | | ||
| 1 | + | Test.java:16:3:16:11 | reference | command-injection, path-injection, request-forgery, sql-injection\nrelated locations: $@.\nmetadata: $@, $@, $@, $@, $@, $@, $@, $@. | Test.java:16:3:16:24 | set(...) | CallContext | file://java.util.concurrent.atomic:1:1:1:1 | java.util.concurrent.atomic | package | file://AtomicReference:1:1:1:1 | AtomicReference | type | file://false:1:1:1:1 | false | subtypes | file://set:1:1:1:1 | set | name | file://(String):1:1:1:1 | (String) | signature | file://Argument[this]:1:1:1:1 | Argument[this] | input | file://false:1:1:1:1 | false | isVarargsArray | file://false:1:1:1:1 | false | alreadyAiModeled | | ||
| 2 | + | Test.java:21:3:21:10 | supplier | command-injection, path-injection, request-forgery, sql-injection\nrelated locations: $@.\nmetadata: $@, $@, $@, $@, $@, $@, $@, $@. | Test.java:21:3:21:16 | get(...) | CallContext | file://java.util.function:1:1:1:1 | java.util.function | package | file://Supplier:1:1:1:1 | Supplier | type | file://true:1:1:1:1 | true | subtypes | file://get:1:1:1:1 | get | name | file://():1:1:1:1 | () | signature | file://Argument[this]:1:1:1:1 | Argument[this] | input | file://false:1:1:1:1 | false | isVarargsArray | file://false:1:1:1:1 | false | alreadyAiModeled | | ||
| 3 | + | Test.java:34:4:34:11 | openPath | command-injection, request-forgery, sql-injection\nrelated locations: $@.\nmetadata: $@, $@, $@, $@, $@, $@, $@, $@. | Test.java:33:10:35:3 | newInputStream(...) | CallContext | file://java.nio.file:1:1:1:1 | java.nio.file | package | file://Files:1:1:1:1 | Files | type | file://false:1:1:1:1 | false | subtypes | file://newInputStream:1:1:1:1 | newInputStream | name | file://(Path,OpenOption[]):1:1:1:1 | (Path,OpenOption[]) | signature | file://Argument[0]:1:1:1:1 | Argument[0] | input | file://false:1:1:1:1 | false | isVarargsArray | file://true:1:1:1:1 | true | alreadyAiModeled | | ||
| 4 | + | Test.java:53:4:53:4 | o | command-injection, path-injection, request-forgery, sql-injection\nrelated locations: $@.\nmetadata: $@, $@, $@, $@, $@, $@, $@, $@. | Test.java:51:3:56:3 | walk(...) | CallContext | file://java.nio.file:1:1:1:1 | java.nio.file | package | file://Files:1:1:1:1 | Files | type | file://false:1:1:1:1 | false | subtypes | file://walk:1:1:1:1 | walk | name | file://(Path,FileVisitOption[]):1:1:1:1 | (Path,FileVisitOption[]) | signature | file://Argument[1]:1:1:1:1 | Argument[1] | input | file://true:1:1:1:1 | true | isVarargsArray | file://false:1:1:1:1 | false | alreadyAiModeled | | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,7 +31,7 @@ public static void copyFiles(Path source, Path target, CopyOption option) throws | |||
| 31 | 31 | ||
| 32 | 32 | public static InputStream getInputStream(Path openPath) throws Exception { | |
| 33 | 33 | return Files.newInputStream( | |
| 34 | - openPath // positive example (known sink) | ||
| 34 | + openPath // positive example (known sink), candidate ("only" ai-modeled, and useful as a candidate in regression testing) | ||
| 35 | 35 | ); | |
| 36 | 36 | } | |
| 37 | 37 | ||
@@ -56,4 +56,3 @@ public static void FilesWalkExample(Path p, FileVisitOption o) throws Exception | |||
| 56 | 56 | ); | |
| 57 | 57 | } | |
| 58 | 58 | } | |
| 59 | - | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments