Skip to content

Commit 3b12cdf

Browse files
committed
Handle missing location data
* Use the file location only if no line/col data * Use the col start line if available, otherwise choose col 0 * Use the end line deduction if available, otherwise use 1 past the start
1 parent f503dcd commit 3b12cdf

File tree

1 file changed

+27
-10
lines changed
  • javascript/frameworks/cap/lib/advanced_security/javascript/frameworks/cap

1 file changed

+27
-10
lines changed

javascript/frameworks/cap/lib/advanced_security/javascript/frameworks/cap/CDL.qll

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,35 @@ abstract class CdlObject extends JsonObject {
1919
f.getAbsolutePath()
2020
.matches("%" + locValue.getPropValue("file").getStringValue() + ".json")
2121
).getAbsolutePath().regexpReplaceAll("\\.json$", "") and
22-
sl = locValue.getPropValue("line").getIntValue() and
23-
sc = locValue.getPropValue("col").getIntValue() and
24-
if exists(getObjectLocationName())
22+
if
23+
not exists(locValue.getPropValue("line")) and
24+
not exists(locValue.getPropValue("col"))
2525
then
26-
// Currently $locations does not provide an end location. However, we can
27-
// automatically deduce the end location from the length of the name.
28-
el = sl and
29-
ec = sc + getObjectLocationName().length() - 1
26+
// We don't know where this entity starts, so mark the whole file
27+
sl = 0 and
28+
sc = 0 and
29+
el = 0 and
30+
ec = 0
3031
else (
31-
// We don't know where this entity ends, so mark the whole line
32-
el = sl + 1 and
33-
ec = 1
32+
sl = locValue.getPropValue("line").getIntValue() and
33+
(
34+
if exists(locValue.getPropValue("col"))
35+
then sc = locValue.getPropValue("col").getIntValue()
36+
else
37+
// We don't know where this entity starts, so mark the start of the line
38+
sc = 0
39+
) and
40+
el = sl and
41+
(
42+
if exists(getObjectLocationName())
43+
then
44+
// Currently $locations does not provide an end location. However, we can
45+
// automatically deduce the end location from the length of the name.
46+
ec = sc + getObjectLocationName().length() - 1
47+
else
48+
// Mark a single character if we cannot predicate the length
49+
ec = sc + 1
50+
)
3451
)
3552
)
3653
else super.getLocation().hasLocationInfo(path, sl, sc, el, ec)

0 commit comments

Comments
 (0)