File tree Expand file tree Collapse file tree 2 files changed +16
-6
lines changed
lib/semmle/python/security/dataflow
src/experimental/Security/CWE-176 Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -63,13 +63,18 @@ deprecated class Configuration extends TaintTracking::Configuration {
6363 }
6464}
6565
66+ abstract private class NormalizationState extends string {
67+ bindingset [ this ]
68+ NormalizationState ( ) { any ( ) }
69+ }
70+
6671/** A state signifying that the file path has not been normalized. */
67- class NotNormalized extends DataFlow :: FlowState {
72+ class NotNormalized extends NormalizationState {
6873 NotNormalized ( ) { this = "NotNormalized" }
6974}
7075
7176/** A state signifying that the file path has been normalized, but not checked. */
72- class NormalizedUnchecked extends DataFlow :: FlowState {
77+ class NormalizedUnchecked extends NormalizationState {
7378 NormalizedUnchecked ( ) { this = "NormalizedUnchecked" }
7479}
7580
@@ -85,7 +90,7 @@ class NormalizedUnchecked extends DataFlow::FlowState {
8590 * Such checks are ineffective in the `NotNormalized` state.
8691 */
8792module PathInjectionConfig implements DataFlow:: StateConfigSig {
88- class FlowState = DataFlow :: FlowState ;
93+ class FlowState = NormalizationState ;
8994
9095 predicate isSource ( DataFlow:: Node source , FlowState state ) {
9196 source instanceof Source and state instanceof NotNormalized
Original file line number Diff line number Diff line change @@ -12,13 +12,18 @@ import semmle.python.dataflow.new.internal.TaintTrackingPrivate
1212import semmle.python.dataflow.new.RemoteFlowSources
1313import UnicodeBypassValidationCustomizations:: UnicodeBypassValidation
1414
15+ abstract private class ValidationState extends string {
16+ bindingset [ this ]
17+ ValidationState ( ) { any ( ) }
18+ }
19+
1520/** A state signifying that a logical validation has not been performed. */
16- class PreValidation extends DataFlow :: FlowState {
21+ class PreValidation extends ValidationState {
1722 PreValidation ( ) { this = "PreValidation" }
1823}
1924
2025/** A state signifying that a logical validation has been performed. */
21- class PostValidation extends DataFlow :: FlowState {
26+ class PostValidation extends ValidationState {
2227 PostValidation ( ) { this = "PostValidation" }
2328}
2429
@@ -29,7 +34,7 @@ class PostValidation extends DataFlow::FlowState {
2934 * to track the requirement that a logical validation has been performed before the Unicode Transformation.
3035 */
3136private module UnicodeBypassValidationConfig implements DataFlow:: StateConfigSig {
32- class FlowState = DataFlow :: FlowState ;
37+ class FlowState = ValidationState ;
3338
3439 predicate isSource ( DataFlow:: Node source , FlowState state ) {
3540 source instanceof RemoteFlowSource and state instanceof PreValidation
You can’t perform that action at this time.
0 commit comments