Skip to content

Commit 75a15e2

Browse files
committed
Add SARIF parsing test
1 parent bd4f56e commit 75a15e2

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import 'mocha';
2+
import { expect } from "chai";
3+
4+
import { parseSarifPlainTextMessage } from '../../sarif-utils';
5+
6+
7+
describe('parsing sarif', () => {
8+
it('should be able to parse a simple message from the spec', async function() {
9+
const message = "Tainted data was used. The data came from [here](3)."
10+
const results = parseSarifPlainTextMessage(message);
11+
expect(results).to.deep.equal([
12+
"Tainted data was used. The data came from ",
13+
{ dest: 3, text: "here" }, "."
14+
]);
15+
});
16+
17+
it('should be able to parse a complex message from the spec', async function() {
18+
const message = "Prohibited term used in [para\\[0\\]\\\\spans\\[2\\]](1)."
19+
const results = parseSarifPlainTextMessage(message);
20+
expect(results).to.deep.equal([
21+
"Prohibited term used in ",
22+
{ dest: 1, text: "para[0]\\spans[2]" }, "."
23+
]);
24+
});
25+
it('should be able to parse a broken complex message from the spec', async function() {
26+
const message = "Prohibited term used in [para\\[0\\]\\\\spans\\[2\\](1)."
27+
const results = parseSarifPlainTextMessage(message);
28+
expect(results).to.deep.equal([
29+
"Prohibited term used in [para[0]\\spans[2](1)."
30+
]);
31+
});
32+
it('should be able to parse a message with extra escaping the spec', async function() {
33+
const message = "Tainted data was used. The data came from \\[here](3)."
34+
const results = parseSarifPlainTextMessage(message);
35+
expect(results).to.deep.equal([
36+
"Tainted data was used. The data came from [here](3)."
37+
]);
38+
});
39+
});

0 commit comments

Comments
 (0)