Make NumericOrBooleanSanitizer easier to access and rename it

This commit is contained in:
Owen Mansel-Chan
2025-10-09 11:34:14 +01:00
parent 2918d30697
commit 0c9cd09140
2 changed files with 21 additions and 5 deletions

View File

@@ -0,0 +1,16 @@
/**
* Classes to represent sanitizers commonly used in dataflow and taint tracking
* configurations.
*/
import go
/**
* A node whose type is a simple type unlikely to carry taint, such as a
* numeric or boolean type.
*/
class SimpleTypeSanitizer extends DataFlow::Node {
SimpleTypeSanitizer() {
this.getType() instanceof NumericType or this.getType() instanceof BoolType
}
}

View File

@@ -4,6 +4,7 @@
*/ */
import go import go
private import semmle.go.security.Sanitizers
/** /**
* Provides extension points for customizing the taint tracking configuration for reasoning about * Provides extension points for customizing the taint tracking configuration for reasoning about
@@ -39,12 +40,11 @@ module SqlInjection {
/** A NoSql query, considered as a taint sink for SQL injection. */ /** A NoSql query, considered as a taint sink for SQL injection. */
class NoSqlQueryAsSink extends Sink instanceof NoSql::Query { } class NoSqlQueryAsSink extends Sink instanceof NoSql::Query { }
/** DEPRECATED: Use `SimpleTypeSanitizer` from semmle.go.security.Sanitizers instead. */
deprecated class NumericOrBooleanSanitizer = SimpleTypeSanitizer;
/** /**
* A numeric- or boolean-typed node, considered a sanitizer for sql injection. * A numeric- or boolean-typed node, considered a sanitizer for sql injection.
*/ */
class NumericOrBooleanSanitizer extends Sanitizer { private class DefaultSanitizer extends Sanitizer instanceof SimpleTypeSanitizer { }
NumericOrBooleanSanitizer() {
this.getType() instanceof NumericType or this.getType() instanceof BoolType
}
}
} }