Skip to content

Commit 32c4cf5

Browse files
Apply suggestions from code review
Co-authored-by: Alex Ford <[email protected]>
1 parent 8251ad5 commit 32c4cf5

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module UnsafeHtmlConstruction {
3636
private import codeql.ruby.security.XSS::ReflectedXss as ReflectedXss
3737

3838
/** Gets a node that eventually ends up in the XSS `sink`. */
39-
DataFlow::Node getANodeThatEndsInXssSink(ReflectedXss::Sink sink) {
39+
private DataFlow::Node getANodeThatEndsInXssSink(ReflectedXss::Sink sink) {
4040
result = getANodeThatEndsInXssSink(TypeTracker::TypeBackTracker::end(), sink)
4141
}
4242

@@ -55,10 +55,10 @@ module UnsafeHtmlConstruction {
5555
}
5656

5757
/**
58-
* A string constructed from a string-literal (e.g. `"foo #{sink}"`),
58+
* A component of a string-literal (e.g. `"foo #{sink}"`),
5959
* where the resulting string ends up being used in an XSS sink.
6060
*/
61-
class StringFormatAsSink extends Sink {
61+
private class StringFormatAsSink extends Sink {
6262
ReflectedXss::Sink s;
6363

6464
StringFormatAsSink() {
@@ -73,13 +73,13 @@ module UnsafeHtmlConstruction {
7373
override string getSinkType() { result = "string interpolation" }
7474
}
7575

76-
import codeql.ruby.security.TaintedFormatStringSpecific as TaintedFormat
76+
private import codeql.ruby.security.TaintedFormatStringSpecific as TaintedFormat
7777

7878
/**
79-
* A string constructed from a printf-style call,
79+
* An argument to a printf-style call,
8080
* where the resulting string ends up being used in an XSS sink.
8181
*/
82-
class TaintedFormatStringAsSink extends Sink {
82+
private class TaintedFormatStringAsSink extends Sink {
8383
ReflectedXss::Sink s;
8484

8585
TaintedFormatStringAsSink() {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ private import codeql.ruby.dataflow.BarrierGuards
1515
* A taint-tracking configuration for detecting unsafe HTML construction.
1616
*/
1717
class Configuration extends TaintTracking::Configuration {
18-
Configuration() { this = "UnsafeShellCommandConstruction" }
18+
Configuration() { this = "UnsafeHtmlConstruction" }
1919

2020
override predicate isSource(DataFlow::Node source) { source instanceof Source }
2121

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class UsersController < ActionController::Base
22
# BAD - create a user description, where the name is not escaped
33
def create_user_description (name)
4-
"<h2>#{name}</h2>".html_safe
4+
"<b>#{name}</b>".html_safe
55
end
66
end
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class UsersController < ActionController::Base
22
# Good - create a user description, where the name is escaped
33
def create_user_description (name)
4-
"<h2>#{ERB::Util.html_escape(name)}</h2>".html_safe
4+
"<b>#{ERB::Util.html_escape(name)}</b>".html_safe
55
end
66
end

0 commit comments

Comments
 (0)