Skip to content

Commit 32502d5

Browse files
author
Stephan Brandauer
committed
Java: Automodel, remove erroneousEndpoints predicate from production queries
1 parent 5d608ac commit 32502d5

6 files changed

+0
-150
lines changed

java/ql/automodel/src/AutomodelApplicationModeCharacteristics.qll

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -569,72 +569,3 @@ private class CannotBeTaintedCharacteristic extends CharacteristicsImpl::LikelyN
569569
FlowSummaryImpl::Private::Steps::summarySetterStep(_, _, e.asNode(), _)
570570
}
571571
}
572-
573-
/**
574-
* Holds if the given endpoint has a self-contradictory combination of characteristics. Detects errors in our endpoint
575-
* characteristics. Lists the problematic characteristics and their implications for all such endpoints, together with
576-
* an error message indicating why this combination is problematic.
577-
*
578-
* Copied from
579-
* javascript/ql/experimental/adaptivethreatmodeling/test/endpoint_large_scale/ContradictoryEndpointCharacteristics.ql
580-
*/
581-
predicate erroneousEndpoints(
582-
Endpoint endpoint, EndpointCharacteristic characteristic,
583-
AutomodelEndpointTypes::EndpointType endpointType, float confidence, string errorMessage,
584-
boolean ignoreKnownModelingErrors
585-
) {
586-
// An endpoint's characteristics should not include positive indicators with medium/high confidence for more than one
587-
// sink/source type (including the negative type).
588-
exists(
589-
EndpointCharacteristic characteristic2, AutomodelEndpointTypes::EndpointType endpointClass2,
590-
float confidence2
591-
|
592-
endpointType != endpointClass2 and
593-
(
594-
endpointType instanceof AutomodelEndpointTypes::SinkType and
595-
endpointClass2 instanceof AutomodelEndpointTypes::SinkType
596-
or
597-
endpointType instanceof AutomodelEndpointTypes::SourceType and
598-
endpointClass2 instanceof AutomodelEndpointTypes::SourceType
599-
) and
600-
characteristic.appliesToEndpoint(endpoint) and
601-
characteristic2.appliesToEndpoint(endpoint) and
602-
characteristic.hasImplications(endpointType, true, confidence) and
603-
characteristic2.hasImplications(endpointClass2, true, confidence2) and
604-
confidence > SharedCharacteristics::mediumConfidence() and
605-
confidence2 > SharedCharacteristics::mediumConfidence() and
606-
(
607-
ignoreKnownModelingErrors = true and
608-
not knownOverlappingCharacteristics(characteristic, characteristic2)
609-
or
610-
ignoreKnownModelingErrors = false
611-
)
612-
) and
613-
errorMessage = "Endpoint has high-confidence positive indicators for multiple classes"
614-
or
615-
// An endpoint's characteristics should not include positive indicators with medium/high confidence for some class and
616-
// also include negative indicators with medium/high confidence for this same class.
617-
exists(EndpointCharacteristic characteristic2, float confidence2 |
618-
characteristic.appliesToEndpoint(endpoint) and
619-
characteristic2.appliesToEndpoint(endpoint) and
620-
characteristic.hasImplications(endpointType, true, confidence) and
621-
characteristic2.hasImplications(endpointType, false, confidence2) and
622-
confidence > SharedCharacteristics::mediumConfidence() and
623-
confidence2 > SharedCharacteristics::mediumConfidence()
624-
) and
625-
ignoreKnownModelingErrors = false and
626-
errorMessage = "Endpoint has high-confidence positive and negative indicators for the same class"
627-
}
628-
629-
/**
630-
* Holds if `characteristic1` and `characteristic2` are among the pairs of currently known positive characteristics that
631-
* have some overlap in their results. This indicates a problem with the underlying Java modeling. Specifically,
632-
* `PathCreation` is prone to FPs.
633-
*/
634-
private predicate knownOverlappingCharacteristics(
635-
EndpointCharacteristic characteristic1, EndpointCharacteristic characteristic2
636-
) {
637-
characteristic1 != characteristic2 and
638-
characteristic1 = ["mad taint step", "create path", "read file", "known non-sink"] and
639-
characteristic2 = ["mad taint step", "create path", "read file", "known non-sink"]
640-
}

java/ql/automodel/src/AutomodelApplicationModeExtractNegativeExamples.ql

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ where
5050
extensibleType = endpoint.getExtensibleType() and
5151
confidence >= SharedCharacteristics::highConfidence() and
5252
characteristic.hasImplications(any(NegativeSinkType negative), true, confidence) and
53-
// Exclude endpoints that have contradictory endpoint characteristics, because we only want examples we're highly
54-
// certain about in the prompt.
55-
not erroneousEndpoints(endpoint, _, _, _, _, false) and
5653
meta.hasMetadata(endpoint, package, type, subtypes, name, signature, input, output, isVarargsArray) and
5754
// It's valid for a node to satisfy the logic for both `isSink` and `isSanitizer`, but in that case it will be
5855
// treated by the actual query as a sanitizer, since the final logic is something like

java/ql/automodel/src/AutomodelApplicationModeExtractPositiveExamples.ql

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ from
1818
DollarAtString signature, DollarAtString input, DollarAtString output,
1919
DollarAtString isVarargsArray, DollarAtString extensibleType
2020
where
21-
// Exclude endpoints that have contradictory endpoint characteristics, because we only want examples we're highly
22-
// certain about in the prompt.
23-
not erroneousEndpoints(endpoint, _, _, _, _, false) and
2421
extensibleType = endpoint.getExtensibleType() and
2522
meta.hasMetadata(endpoint, package, type, subtypes, name, signature, input, output, isVarargsArray) and
2623
// Extract positive examples of sinks belonging to the existing ATM query configurations.

java/ql/automodel/src/AutomodelFrameworkModeCharacteristics.qll

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -385,72 +385,3 @@ private class NonPublicMethodCharacteristic extends CharacteristicsImpl::Uninter
385385

386386
override predicate appliesToEndpoint(Endpoint e) { not e.getEnclosingCallable().isPublic() }
387387
}
388-
389-
/**
390-
* Holds if the given endpoint has a self-contradictory combination of characteristics. Detects errors in our endpoint
391-
* characteristics. Lists the problematic characteristics and their implications for all such endpoints, together with
392-
* an error message indicating why this combination is problematic.
393-
*
394-
* Copied from
395-
* javascript/ql/experimental/adaptivethreatmodeling/test/endpoint_large_scale/ContradictoryEndpointCharacteristics.ql
396-
*/
397-
predicate erroneousEndpoints(
398-
Endpoint endpoint, EndpointCharacteristic characteristic,
399-
AutomodelEndpointTypes::EndpointType endpointType, float confidence, string errorMessage,
400-
boolean ignoreKnownModelingErrors
401-
) {
402-
// An endpoint's characteristics should not include positive indicators with medium/high confidence for more than one
403-
// sink/source type (including the negative type).
404-
exists(
405-
EndpointCharacteristic characteristic2, AutomodelEndpointTypes::EndpointType endpointClass2,
406-
float confidence2
407-
|
408-
endpointType != endpointClass2 and
409-
(
410-
endpointType instanceof AutomodelEndpointTypes::SinkType and
411-
endpointClass2 instanceof AutomodelEndpointTypes::SinkType
412-
or
413-
endpointType instanceof AutomodelEndpointTypes::SourceType and
414-
endpointClass2 instanceof AutomodelEndpointTypes::SourceType
415-
) and
416-
characteristic.appliesToEndpoint(endpoint) and
417-
characteristic2.appliesToEndpoint(endpoint) and
418-
characteristic.hasImplications(endpointType, true, confidence) and
419-
characteristic2.hasImplications(endpointClass2, true, confidence2) and
420-
confidence > SharedCharacteristics::mediumConfidence() and
421-
confidence2 > SharedCharacteristics::mediumConfidence() and
422-
(
423-
ignoreKnownModelingErrors = true and
424-
not knownOverlappingCharacteristics(characteristic, characteristic2)
425-
or
426-
ignoreKnownModelingErrors = false
427-
)
428-
) and
429-
errorMessage = "Endpoint has high-confidence positive indicators for multiple classes"
430-
or
431-
// An endpoint's characteristics should not include positive indicators with medium/high confidence for some class and
432-
// also include negative indicators with medium/high confidence for this same class.
433-
exists(EndpointCharacteristic characteristic2, float confidence2 |
434-
characteristic.appliesToEndpoint(endpoint) and
435-
characteristic2.appliesToEndpoint(endpoint) and
436-
characteristic.hasImplications(endpointType, true, confidence) and
437-
characteristic2.hasImplications(endpointType, false, confidence2) and
438-
confidence > SharedCharacteristics::mediumConfidence() and
439-
confidence2 > SharedCharacteristics::mediumConfidence()
440-
) and
441-
ignoreKnownModelingErrors = false and
442-
errorMessage = "Endpoint has high-confidence positive and negative indicators for the same class"
443-
}
444-
445-
/**
446-
* Holds if `characteristic1` and `characteristic2` are among the pairs of currently known positive characteristics that
447-
* have some overlap in their results. This indicates a problem with the underlying Java modeling. Specifically,
448-
* `PathCreation` is prone to FPs.
449-
*/
450-
private predicate knownOverlappingCharacteristics(
451-
EndpointCharacteristic characteristic1, EndpointCharacteristic characteristic2
452-
) {
453-
characteristic1 != characteristic2 and
454-
characteristic1 = ["mad taint step", "create path", "read file", "known non-sink"] and
455-
characteristic2 = ["mad taint step", "create path", "read file", "known non-sink"]
456-
}

java/ql/automodel/src/AutomodelFrameworkModeExtractNegativeExamples.ql

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ where
2323
characteristic.appliesToEndpoint(endpoint) and
2424
confidence >= SharedCharacteristics::highConfidence() and
2525
characteristic.hasImplications(any(NegativeSinkType negative), true, confidence) and
26-
// Exclude endpoints that have contradictory endpoint characteristics, because we only want examples we're highly
27-
// certain about in the prompt.
28-
not erroneousEndpoints(endpoint, _, _, _, _, false) and
2926
meta.hasMetadata(endpoint, package, type, subtypes, name, signature, input, output, parameterName) and
3027
// It's valid for a node to satisfy the logic for both `isSink` and `isSanitizer`, but in that case it will be
3128
// treated by the actual query as a sanitizer, since the final logic is something like

java/ql/automodel/src/AutomodelFrameworkModeExtractPositiveExamples.ql

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ from
1919
DollarAtString extensibleType
2020
where
2121
endpoint.getExtensibleType() = extensibleType and
22-
// Exclude endpoints that have contradictory endpoint characteristics, because we only want examples we're highly
23-
// certain about in the prompt.
24-
not erroneousEndpoints(endpoint, _, _, _, _, false) and
2522
meta.hasMetadata(endpoint, package, type, subtypes, name, signature, input, output, parameterName) and
2623
// Extract positive examples of sinks belonging to the existing ATM query configurations.
2724
CharacteristicsImpl::isKnownAs(endpoint, sinkType, _)

0 commit comments

Comments
 (0)