Skip to content

Commit db3bf0e

Browse files
committed
use the sanitizers from ReflectedXSS in unsafe-html-construction
1 parent 0bb86fc commit db3bf0e

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

ruby/ql/lib/codeql/ruby/security/UnsafeHtmlConstructionCustomizations.qll

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
private import ruby
88
private import codeql.ruby.ApiGraphs
99
private import codeql.ruby.frameworks.core.Gem::Gem as Gem
10+
private import codeql.ruby.security.XSS::ReflectedXss as ReflectedXss
1011
private import codeql.ruby.typetracking.TypeTracking
1112

1213
/**
@@ -34,7 +35,11 @@ module UnsafeHtmlConstruction {
3435
abstract string getSinkType();
3536
}
3637

37-
private import codeql.ruby.security.XSS::ReflectedXss as ReflectedXss
38+
/** A sanitizer for HTML constructed from library input vulnerabilities. */
39+
abstract class Sanitizer extends DataFlow::Node { }
40+
41+
// inherit all the sanitizers from ReflectedXss
42+
class ReflectedXssSanitizers extends Sanitizer instanceof ReflectedXss::Sanitizer { }
3843

3944
/** Gets a node that eventually ends up in the XSS `sink`. */
4045
private DataFlow::Node getANodeThatEndsInXssSink(ReflectedXss::Sink sink) {

ruby/ql/lib/codeql/ruby/security/UnsafeHtmlConstructionQuery.qll

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ deprecated class Configuration extends TaintTracking::Configuration {
2323

2424
override predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
2525

26-
override predicate isSanitizer(DataFlow::Node node) {
27-
node instanceof StringConstCompareBarrier or
28-
node instanceof StringConstArrayInclusionCallBarrier
29-
}
26+
override predicate isSanitizer(DataFlow::Node node) { node instanceof Sanitizer }
3027

3128
// override to require the path doesn't have unmatched return steps
3229
override DataFlow::FlowFeature getAFeature() {
@@ -39,10 +36,7 @@ private module UnsafeHtmlConstructionConfig implements DataFlow::ConfigSig {
3936

4037
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
4138

42-
predicate isBarrier(DataFlow::Node node) {
43-
node instanceof StringConstCompareBarrier or
44-
node instanceof StringConstArrayInclusionCallBarrier
45-
}
39+
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
4640

4741
// override to require the path doesn't have unmatched return steps
4842
DataFlow::FlowFeature getAFeature() { result instanceof DataFlow::FeatureHasSourceCallContext }

0 commit comments

Comments
 (0)