Skip to content

Commit 0cf0aac

Browse files
authored
Merge pull request #21109 from owen-mc/go/misc-trivial-fixes
Go: misc trivial fixes
2 parents 17a453b + 16113e6 commit 0cf0aac

24 files changed

+262
-229
lines changed

go/ql/lib/semmle/go/frameworks/K8sIoApimachineryPkgRuntime.qll

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ module K8sIoApimachineryPkgRuntime {
5050
}
5151
}
5252

53-
private class DecoderDecode extends Method, UnmarshalingFunction::Range {
53+
private class DecoderDecode extends UnmarshalingFunction::Range, Method {
5454
DecoderDecode() {
5555
this.implements(packagePath(), "Decoder", "Decode") or
5656
this.hasQualifiedName(packagePath(), "WithoutVersionDecoder", "Decode")
@@ -95,7 +95,7 @@ module K8sIoApimachineryPkgRuntime {
9595
}
9696
}
9797

98-
private class ParameterCodecDecodeParameters extends Method, UnmarshalingFunction::Range {
98+
private class ParameterCodecDecodeParameters extends UnmarshalingFunction::Range, Method {
9999
ParameterCodecDecodeParameters() {
100100
this.implements(packagePath(), "ParameterCodec", "DecodeParameters")
101101
}
@@ -110,7 +110,7 @@ module K8sIoApimachineryPkgRuntime {
110110
}
111111
}
112112

113-
private class ParameterCodecEncodeParameters extends Method, MarshalingFunction::Range {
113+
private class ParameterCodecEncodeParameters extends MarshalingFunction::Range, Method {
114114
ParameterCodecEncodeParameters() {
115115
this.implements(packagePath(), "ParameterCodec", "EncodeParameters")
116116
}
@@ -125,7 +125,7 @@ module K8sIoApimachineryPkgRuntime {
125125
}
126126
}
127127

128-
private class ProtobufMarshallerMarshalTo extends Method, MarshalingFunction::Range {
128+
private class ProtobufMarshallerMarshalTo extends MarshalingFunction::Range, Method {
129129
ProtobufMarshallerMarshalTo() {
130130
this.implements(packagePath(), "ProtobufMarshaller", "MarshalTo") or
131131
this.implements(packagePath(), "ProtobufReverseMarshaller", "MarshalToSizedBuffer")
@@ -138,7 +138,7 @@ module K8sIoApimachineryPkgRuntime {
138138
override string getFormat() { result = "protobuf" }
139139
}
140140

141-
private class RawExtensionMarshal extends Method, MarshalingFunction::Range {
141+
private class RawExtensionMarshal extends MarshalingFunction::Range, Method {
142142
RawExtensionMarshal() { this.hasQualifiedName(packagePath(), "RawExtension", "Marshal") }
143143

144144
override DataFlow::FunctionInput getAnInput() { result.isReceiver() }
@@ -148,7 +148,7 @@ module K8sIoApimachineryPkgRuntime {
148148
override string getFormat() { result = "protobuf" }
149149
}
150150

151-
private class RawExtensionUnmarshal extends Method, UnmarshalingFunction::Range {
151+
private class RawExtensionUnmarshal extends UnmarshalingFunction::Range, Method {
152152
RawExtensionUnmarshal() { this.hasQualifiedName(packagePath(), "RawExtension", "Unmarshal") }
153153

154154
override DataFlow::FunctionInput getAnInput() { result.isReceiver() }
@@ -158,7 +158,7 @@ module K8sIoApimachineryPkgRuntime {
158158
override string getFormat() { result = "protobuf" }
159159
}
160160

161-
private class UnknownMarshal extends Method, MarshalingFunction::Range {
161+
private class UnknownMarshal extends MarshalingFunction::Range, Method {
162162
string methodName;
163163

164164
UnknownMarshal() {
@@ -177,7 +177,7 @@ module K8sIoApimachineryPkgRuntime {
177177
override string getFormat() { result = "protobuf" }
178178
}
179179

180-
private class UnknownUnmarshal extends Method, UnmarshalingFunction::Range {
180+
private class UnknownUnmarshal extends UnmarshalingFunction::Range, Method {
181181
UnknownUnmarshal() { this.hasQualifiedName(packagePath(), "Unknown", "Unmarshal") }
182182

183183
override DataFlow::FunctionInput getAnInput() { result.isReceiver() }

go/ql/lib/semmle/go/frameworks/Revel.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ module Revel {
140140
/**
141141
* A render of a template.
142142
*/
143-
abstract class TemplateRender extends DataFlow::Node, TemplateInstantiation::Range {
143+
abstract class TemplateRender extends TemplateInstantiation::Range {
144144
/** Gets the name of the file that is rendered. */
145145
abstract File getRenderedFile();
146146

go/ql/lib/semmle/go/frameworks/stdlib/NetHttp.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ module NetHttp {
4646
}
4747
}
4848

49-
private class MapWrite extends Http::HeaderWrite::Range, DataFlow::Node {
49+
private class MapWrite extends Http::HeaderWrite::Range {
5050
DataFlow::Node index;
5151
DataFlow::Node rhs;
5252

go/ql/lib/semmle/go/frameworks/stdlib/Regexp.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ module Regexp {
6161
}
6262
}
6363

64-
private class ExternalRegexpMatchFunction extends RegexpMatchFunction::Range, Function {
64+
private class ExternalRegexpMatchFunction extends RegexpMatchFunction::Range {
6565
int patArg;
6666
int strArg;
6767

go/ql/lib/semmle/go/security/CleartextLoggingCustomizations.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ module CleartextLogging {
120120
*
121121
* This is a source since `log.Print(obj)` will often show the fields of `obj`.
122122
*/
123-
private class StructPasswordFieldSource extends DataFlow::Node, Source {
123+
private class StructPasswordFieldSource extends Source {
124124
string name;
125125

126126
StructPasswordFieldSource() {
@@ -137,7 +137,7 @@ module CleartextLogging {
137137
}
138138

139139
/** An access to a variable or property that might contain a password. */
140-
private class ReadPasswordSource extends DataFlow::Node, Source {
140+
private class ReadPasswordSource extends Source {
141141
string name;
142142

143143
ReadPasswordSource() {
@@ -162,7 +162,7 @@ module CleartextLogging {
162162
}
163163

164164
/** A call that might return a password. */
165-
private class CallPasswordSource extends DataFlow::CallNode, Source {
165+
private class CallPasswordSource extends Source, DataFlow::CallNode {
166166
string name;
167167

168168
CallPasswordSource() {

go/ql/lib/semmle/go/security/OpenUrlRedirectCustomizations.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ module OpenUrlRedirect {
6161
/**
6262
* An HTTP redirect, considered as a sink for `Configuration`.
6363
*/
64-
class RedirectSink extends Sink, DataFlow::Node {
64+
class RedirectSink extends Sink {
6565
RedirectSink() { this = any(Http::Redirect redir).getUrl() }
6666
}
6767

6868
/**
6969
* A definition of the HTTP "Location" header, considered as a sink for
7070
* `Configuration`.
7171
*/
72-
class LocationHeaderSink extends Sink, DataFlow::Node {
72+
class LocationHeaderSink extends Sink {
7373
LocationHeaderSink() {
7474
exists(Http::HeaderWrite hw | hw.getHeaderName() = "location" | this = hw.getValue())
7575
}
@@ -99,20 +99,20 @@ module OpenUrlRedirect {
9999
* A call to a function called `isLocalUrl`, `isValidRedirect`, or similar, which is
100100
* considered a barrier guard for sanitizing untrusted URLs.
101101
*/
102-
class RedirectCheckBarrierGuardAsBarrierGuard extends RedirectCheckBarrier, Barrier { }
102+
class RedirectCheckBarrierGuardAsBarrierGuard extends Barrier instanceof RedirectCheckBarrier { }
103103

104104
/**
105105
* A call to a regexp match function, considered as a barrier guard for sanitizing untrusted URLs.
106106
*
107107
* This is overapproximate: we do not attempt to reason about the correctness of the regexp.
108108
*/
109-
class RegexpCheckAsBarrierGuard extends RegexpCheckBarrier, Barrier { }
109+
class RegexpCheckAsBarrierGuard extends Barrier instanceof RegexpCheckBarrier { }
110110

111111
/**
112112
* A check against a constant value or the `Hostname` function,
113113
* considered a barrier guard for url flow.
114114
*/
115-
class UrlCheckAsBarrierGuard extends UrlCheckBarrier, Barrier { }
115+
class UrlCheckAsBarrierGuard extends Barrier instanceof UrlCheckBarrier { }
116116
}
117117

118118
/** A sink for an open redirect, considered as a sink for safe URL flow. */

go/ql/lib/semmle/go/security/RequestForgeryCustomizations.qll

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,15 @@ module RequestForgery {
102102
* A call to a function called `isLocalUrl`, `isValidRedirect`, or similar, which is
103103
* considered a barrier guard.
104104
*/
105-
class RedirectCheckBarrierGuardAsBarrierGuard extends RedirectCheckBarrier, Sanitizer { }
105+
class RedirectCheckBarrierGuardAsBarrierGuard extends Sanitizer instanceof RedirectCheckBarrier {
106+
}
106107

107108
/**
108109
* A call to a regexp match function, considered as a barrier guard for sanitizing untrusted URLs.
109110
*
110111
* This is overapproximate: we do not attempt to reason about the correctness of the regexp.
111112
*/
112-
class RegexpCheckAsBarrierGuard extends RegexpCheckBarrier, Sanitizer { }
113+
class RegexpCheckAsBarrierGuard extends Sanitizer instanceof RegexpCheckBarrier { }
113114

114115
/**
115116
* An equality check comparing a data-flow node against a constant string, considered as
@@ -118,7 +119,7 @@ module RequestForgery {
118119
* Additionally, a check comparing `url.Hostname()` against a constant string is also
119120
* considered a barrier guard for `url`.
120121
*/
121-
class UrlCheckAsBarrierGuard extends UrlCheckBarrier, Sanitizer { }
122+
class UrlCheckAsBarrierGuard extends Sanitizer instanceof UrlCheckBarrier { }
122123

123124
/**
124125
* A simple-typed node, considered a sanitizer for request forgery.

go/ql/lib/semmle/go/security/UnsafeUnzipSymlinkCustomizations.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ module UnsafeUnzipSymlink {
126126
* An argument to a call to `os.Symlink` within a loop that extracts a zip or tar archive,
127127
* taken as a sink for unsafe unzipping of symlinks.
128128
*/
129-
class OsSymlink extends DataFlow::Node, SymlinkSink {
129+
class OsSymlink extends SymlinkSink {
130130
OsSymlink() {
131131
exists(DataFlow::CallNode n | n.asExpr() = getASymlinkCall() |
132132
this = n.getArgument([0, 1]) and
@@ -139,7 +139,7 @@ module UnsafeUnzipSymlink {
139139
* An argument to `path/filepath.EvalSymlinks` or `os.Readlink`, taken as a sink for detecting target
140140
* paths that are likely safe to extract to.
141141
*/
142-
class StdlibSymlinkResolvers extends DataFlow::Node, EvalSymlinksSink {
142+
class StdlibSymlinkResolvers extends EvalSymlinksSink {
143143
StdlibSymlinkResolvers() {
144144
exists(DataFlow::CallNode n |
145145
n.getTarget().hasQualifiedName("path/filepath", "EvalSymlinks")

go/ql/lib/semmle/go/security/Xss.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,14 @@ module SharedXss {
139139
* A `Template` from `html/template` will HTML-escape data automatically
140140
* and therefore acts as a sanitizer for XSS vulnerabilities.
141141
*/
142-
class HtmlTemplateSanitizer extends Sanitizer, DataFlow::Node {
142+
class HtmlTemplateSanitizer extends Sanitizer {
143143
HtmlTemplateSanitizer() {
144144
exists(Method m, DataFlow::CallNode call | m = call.getCall().getTarget() |
145145
m.hasQualifiedName("html/template", "Template", "ExecuteTemplate") and
146-
call.getArgument(2) = this
146+
this = call.getArgument(2)
147147
or
148148
m.hasQualifiedName("html/template", "Template", "Execute") and
149-
call.getArgument(1) = this
149+
this = call.getArgument(1)
150150
)
151151
}
152152
}

go/ql/lib/semmle/go/security/ZipSlipCustomizations.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module ZipSlip {
3030
/**
3131
* A tar file header, as a source for zip slip.
3232
*/
33-
class TarHeaderSource extends Source, DataFlow::Node {
33+
class TarHeaderSource extends Source {
3434
TarHeaderSource() {
3535
this =
3636
any(DataFlow::MethodCallNode mcn |

0 commit comments

Comments
 (0)