Skip to content

Commit c271e52

Browse files
committed
Validate models for barriers and barrier guards
1 parent a7c4ba5 commit c271e52

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

go/ql/lib/semmle/go/dataflow/ExternalFlow.qll

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ module ModelValidation {
129129
summaryModel(_, _, _, _, _, _, path, _, _, _, _) or
130130
summaryModel(_, _, _, _, _, _, _, path, _, _, _) or
131131
sinkModel(_, _, _, _, _, _, path, _, _, _) or
132-
sourceModel(_, _, _, _, _, _, path, _, _, _)
132+
sourceModel(_, _, _, _, _, _, path, _, _, _) or
133+
barrierModel(_, _, _, _, _, _, path, _, _, _) or
134+
barrierGuardModel(_, _, _, _, _, _, path, _, _, _, _)
133135
}
134136

135137
private module MkAccessPath = AccessPathSyntax::AccessPath<getRelevantAccessPath/1>;
@@ -142,6 +144,8 @@ module ModelValidation {
142144
exists(string pred, AccessPath input, AccessPathToken part |
143145
sinkModel(_, _, _, _, _, _, input, _, _, _) and pred = "sink"
144146
or
147+
barrierGuardModel(_, _, _, _, _, _, input, _, _, _, _) and pred = "barrier guard"
148+
or
145149
summaryModel(_, _, _, _, _, _, input, _, _, _, _) and pred = "summary"
146150
|
147151
(
@@ -164,6 +168,8 @@ module ModelValidation {
164168
exists(string pred, AccessPath output, AccessPathToken part |
165169
sourceModel(_, _, _, _, _, _, output, _, _, _) and pred = "source"
166170
or
171+
barrierModel(_, _, _, _, _, _, output, _, _, _) and pred = "barrier"
172+
or
167173
summaryModel(_, _, _, _, _, _, _, output, _, _, _) and pred = "summary"
168174
|
169175
(
@@ -181,7 +187,13 @@ module ModelValidation {
181187
private module KindValConfig implements SharedModelVal::KindValidationConfigSig {
182188
predicate summaryKind(string kind) { summaryModel(_, _, _, _, _, _, _, _, kind, _, _) }
183189

184-
predicate sinkKind(string kind) { sinkModel(_, _, _, _, _, _, _, kind, _, _) }
190+
predicate sinkKind(string kind) {
191+
sinkModel(_, _, _, _, _, _, _, kind, _, _)
192+
or
193+
barrierModel(_, _, _, _, _, _, _, kind, _, _)
194+
or
195+
barrierGuardModel(_, _, _, _, _, _, _, _, kind, _, _)
196+
}
185197

186198
predicate sourceKind(string kind) { sourceModel(_, _, _, _, _, _, _, kind, _, _) }
187199

@@ -199,6 +211,11 @@ module ModelValidation {
199211
or
200212
sinkModel(package, type, _, name, signature, ext, _, _, provenance, _) and pred = "sink"
201213
or
214+
barrierModel(package, type, _, name, signature, ext, _, _, provenance, _) and pred = "barrier"
215+
or
216+
barrierGuardModel(package, type, _, name, signature, ext, _, _, _, provenance, _) and
217+
pred = "barrier guard"
218+
or
202219
summaryModel(package, type, _, name, signature, ext, _, _, _, provenance, _) and
203220
pred = "summary"
204221
or
@@ -224,6 +241,14 @@ module ModelValidation {
224241
invalidProvenance(provenance) and
225242
result = "Unrecognized provenance description \"" + provenance + "\" in " + pred + " model."
226243
)
244+
or
245+
exists(string acceptingvalue |
246+
barrierGuardModel(_, _, _, _, _, _, _, acceptingvalue, _, _, _) and
247+
invalidAcceptingValue(acceptingvalue) and
248+
result =
249+
"Unrecognized accepting value description \"" + acceptingvalue +
250+
"\" in barrier guard model."
251+
)
227252
}
228253

229254
private string getInvalidPackageGroup() {
@@ -232,6 +257,11 @@ module ModelValidation {
232257
or
233258
FlowExtensions::sinkModel(package, _, _, _, _, _, _, _, _, _) and pred = "sink"
234259
or
260+
FlowExtensions::barrierModel(package, _, _, _, _, _, _, _, _, _) and pred = "barrier"
261+
or
262+
FlowExtensions::barrierGuardModel(package, _, _, _, _, _, _, _, _, _, _) and
263+
pred = "barrier guard"
264+
or
235265
FlowExtensions::summaryModel(package, _, _, _, _, _, _, _, _, _, _) and
236266
pred = "summary"
237267
or

0 commit comments

Comments
 (0)