19
19
* reading.
20
20
* 1. The `package` column selects a package. Note that if the package does not
21
21
* contain a major version suffix (like "/v2") then we will match all major
22
- * versions. This can be disabled by putting `$THISVERSION ` at the end of
23
- * the package path.
22
+ * versions. This can be disabled by putting `fixed-version: ` at the start
23
+ * of the package path.
24
24
* 2. The `type` column selects a type within that package.
25
25
* 3. The `subtypes` is a boolean that indicates whether to jump to an
26
26
* arbitrary subtype of that type.
@@ -266,7 +266,7 @@ module ModelValidation {
266
266
ext = "" and
267
267
pred = "neutral"
268
268
|
269
- not package .replaceAll ( "$ANYVERSION" , "" ) .regexpMatch ( "[a-zA-Z0-9_\\./-]*" ) and
269
+ not package .replaceAll ( fixedVersionPrefix ( ) , "" ) .regexpMatch ( "[a-zA-Z0-9_\\./-]*" ) and
270
270
result = "Dubious package \"" + package + "\" in " + pred + " model."
271
271
or
272
272
not type .regexpMatch ( "[a-zA-Z0-9_\\$<>]*" ) and
@@ -309,6 +309,8 @@ private predicate elementSpec(
309
309
neutralModel ( package , type , name , signature , _, _) and ext = "" and subtypes = false
310
310
}
311
311
312
+ private string fixedVersionPrefix ( ) { result = "fixed-version:" }
313
+
312
314
/**
313
315
* Gets the string for the package path corresponding to `p`, if one exists.
314
316
*
@@ -318,17 +320,14 @@ private predicate elementSpec(
318
320
* so if `github.com/a/b/c/d/v2` or `github.com/a/b/v3/c/d` were imported then
319
321
* they will be in the results. There are two situations where we do not do
320
322
* this: (1) when `p` already contains a major version suffix; (2) if `p` has
321
- * `$THISVERSION ` at the end (which we remove).
323
+ * `fixed-version: ` at the start (which we remove).
322
324
*/
323
325
bindingset [ p]
324
326
private string interpretPackage ( string p ) {
325
- exists ( Package pkg , string thisVersion |
326
- result = pkg .getPath ( ) and
327
- thisVersion = "$THISVERSION"
328
- |
329
- p = result + thisVersion
327
+ exists ( Package pkg | result = pkg .getPath ( ) |
328
+ p = fixedVersionPrefix ( ) + result
330
329
or
331
- not p = any ( string s ) + thisVersion and
330
+ not p = fixedVersionPrefix ( ) + any ( string s ) and
332
331
(
333
332
if exists ( p .regexpFind ( majorVersionSuffixRegex ( ) , 0 , _) )
334
333
then result = p
0 commit comments