@@ -19,6 +19,16 @@ abstract class SafeExternalApiFunction extends Function { }
1919/** DEPRECATED: Alias for SafeExternalApiFunction */
2020deprecated class SafeExternalAPIFunction = SafeExternalApiFunction ;
2121
22+ /**
23+ * A `Function` with one or more arguments that are considered "safe" from a security perspective.
24+ */
25+ abstract class SafeExternalApiArgument extends Function {
26+ /**
27+ * Holds if `i` is a safe argument to this function.
28+ */
29+ abstract predicate isSafeArgument ( int i ) ;
30+ }
31+
2232private predicate isDefaultSafePackage ( Package package ) {
2333 package .getPath ( ) in [ "time" , "unicode/utf8" , package ( "gopkg.in/go-playground/validator" , "" ) ]
2434}
@@ -44,6 +54,16 @@ private class DefaultSafeExternalApiFunction extends SafeExternalApiFunction {
4454 }
4555}
4656
57+ private class DefaultSafeExternalApiFunctionArgument extends SafeExternalApiArgument {
58+ int index ;
59+
60+ DefaultSafeExternalApiFunctionArgument ( ) {
61+ this .( Method ) .hasQualifiedName ( "net/http" , "Header" , [ "Set" , "Del" ] ) and index = - 1
62+ }
63+
64+ override predicate isSafeArgument ( int i ) { i = index }
65+ }
66+
4767/** Holds if `callNode` is a local function pointer. */
4868private predicate isProbableLocalFunctionPointer ( DataFlow:: CallNode callNode ) {
4969 // Not a method call
@@ -77,7 +97,9 @@ class ExternalApiDataNode extends DataFlow::Node {
7797 // Not already modeled as a taint step
7898 not TaintTracking:: localTaintStep ( this , _) and
7999 // Not a call to a known safe external API
80- not call .getTarget ( ) instanceof SafeExternalApiFunction
100+ not call .getTarget ( ) instanceof SafeExternalApiFunction and
101+ // Not a known safe argument to an external API
102+ not any ( SafeExternalApiArgument seaa ) .isSafeArgument ( i )
81103 }
82104
83105 /** Gets the called API `Function`. */
0 commit comments