QL code and tests for C#/C++/JavaScript.

This commit is contained in:
Pavel Avgustinov
2018-08-02 17:53:23 +01:00
commit b55526aa58
10684 changed files with 581163 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
| invalid.json:3:1:3:1 | Error: Comments are not legal in JSON. |
| invalid.json:4:1:4:1 | Error: Comments are not legal in JSON. |

View File

@@ -0,0 +1,4 @@
import semmle.javascript.JSON
from JSONParseError jpe
select jpe

View File

@@ -0,0 +1,10 @@
| tst.json:1:2:8:1 | {\\n "na ... "\\n }\\n} | address | tst.json:3:14:7:3 | {\\n " ... nd"\\n } | (none) |
| tst.json:1:2:8:1 | {\\n "na ... "\\n }\\n} | name | tst.json:2:11:2:21 | "Jim Knopf" | Jim Knopf |
| tst.json:3:14:7:3 | {\\n " ... nd"\\n } | country | tst.json:6:16:6:27 | "Lummerland" | Lummerland |
| tst.json:3:14:7:3 | {\\n " ... nd"\\n } | number | tst.json:5:15:5:16 | -1 | (none) |
| tst.json:3:14:7:3 | {\\n " ... nd"\\n } | street | tst.json:4:15:4:18 | null | (none) |
| tst.json:8:4:15:1 | {\\n "na ... "\\n }\\n} | address | tst.json:10:14:14:3 | {\\n " ... nd"\\n } | (none) |
| tst.json:8:4:15:1 | {\\n "na ... "\\n }\\n} | name | tst.json:9:11:9:25 | "Frau Mahlzahn" | Frau Mahlzahn |
| tst.json:10:14:14:3 | {\\n " ... nd"\\n } | country | tst.json:13:16:13:27 | "Kummerland" | Kummerland |
| tst.json:10:14:14:3 | {\\n " ... nd"\\n } | number | tst.json:12:15:12:17 | 133 | (none) |
| tst.json:10:14:14:3 | {\\n " ... nd"\\n } | street | tst.json:11:15:11:28 | "Alte Strasse" | Alte Strasse |

View File

@@ -0,0 +1,9 @@
import semmle.javascript.JSON
from JSONObject obj, string prop, JSONValue val, string strval
where val = obj.getPropValue(prop) and
(if exists(obj.getPropStringValue(prop)) then
strval = obj.getPropStringValue(prop)
else
strval = "(none)")
select obj, prop, val, strval

View File

@@ -0,0 +1,14 @@
| invalid.json:1:1:1:4 | "hi" |
| tst.json:1:1:15:2 | [{\\n "n ... \\n }\\n}] |
| tst.json:1:2:8:1 | {\\n "na ... "\\n }\\n} |
| tst.json:2:11:2:21 | "Jim Knopf" |
| tst.json:3:14:7:3 | {\\n " ... nd"\\n } |
| tst.json:4:15:4:18 | null |
| tst.json:5:15:5:16 | -1 |
| tst.json:6:16:6:27 | "Lummerland" |
| tst.json:8:4:15:1 | {\\n "na ... "\\n }\\n} |
| tst.json:9:11:9:25 | "Frau Mahlzahn" |
| tst.json:10:14:14:3 | {\\n " ... nd"\\n } |
| tst.json:11:15:11:28 | "Alte Strasse" |
| tst.json:12:15:12:17 | 133 |
| tst.json:13:16:13:27 | "Kummerland" |

View File

@@ -0,0 +1,4 @@
import semmle.javascript.JSON
from JSONValue v
select v

View File

@@ -0,0 +1,4 @@
"hi"
// JSON doesn't have comments
// semmle-extractor-options: --tolerate-parse-errors

View File

@@ -0,0 +1,15 @@
[{
"name": "Jim Knopf",
"address": {
"street": null,
"number": -1,
"country": "Lummerland"
}
}, {
"name": "Frau Mahlzahn",
"address": {
"street": "Alte Strasse",
"number": 133,
"country": "Kummerland"
}
}]