Skip to content

Commit 5050b06

Browse files
authored
Remove local souffle (#31)
* Use the external souffle.ts library * Rip out the old souffle boilerplate code * Fix tests that are failing due to non-determinism in call tree rules (paths are non-deterministic) * Fix tests failing due to different ast node ids
1 parent f263a41 commit 5050b06

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+363
-4519
lines changed

package-lock.json

Lines changed: 261 additions & 333 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@
1616
"gen-translation-modules": "node scripts/gen_translation_modules.js && eslint --fix src/gen/translate.ts src/gen/declarations.ts",
1717
"copy-dl": "cp -r src/lib/analyses dist/lib && cp -r src/lib/detectors dist/lib",
1818
"copy-functors": "cp -r functors dist/",
19-
"build-parser": "jison src/lib/souffle/parser/souffle.jison -o src/lib/souffle/parser/souffle_parser_gen.js -m commonjs && cp src/lib/souffle/parser/souffle_parser_gen.js dist/lib/souffle/parser/souffle_parser_gen.js",
20-
"build-expr-parser": "jison src/lib/souffle/parser/souffle_value.jison -o src/lib/souffle/parser/souffle_value_parser_gen.js -m commonjs && cp src/lib/souffle/parser/souffle_value_parser_gen.js dist/lib/souffle/parser/souffle_value_parser_gen.js",
21-
"build-parsers": "npm run build-parser && npm run build-expr-parser",
2219
"build-functors": "./scripts/build_functors.sh",
23-
"build": "npm run clean && npm run gen-translation-modules && npm run transpile && npm run build-parsers && chmod a+x dist/bin/cli.js && npm run copy-dl && npm run build-functors && npm run copy-functors",
20+
"build": "npm run clean && npm run gen-translation-modules && npm run transpile && chmod a+x dist/bin/cli.js && npm run copy-dl && npm run build-functors && npm run copy-functors",
2421
"test": "c8 mocha",
2522
"lint": "eslint src/ test/ --ext=ts",
2623
"lint:fix": "eslint src/ test/ --ext=ts --fix",
@@ -34,7 +31,8 @@
3431
"fs-extra": "^11.2.0",
3532
"solc-typed-ast": "^18.1.2",
3633
"sqlite": "^5.1.1",
37-
"sqlite3": "^5.1.7"
34+
"sqlite3": "^5.1.7",
35+
"souffle.ts": "^0.1.5"
3836
},
3937
"devDependencies": {
4038
"@ts-ast-parser/core": "^0.7.0",

scripts/build_functors.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ MY_DIR=$(cd $(dirname $0) && pwd)
44
FUNCTOR_DIR=$MY_DIR/../functors/
55

66
echo "Building functors..."
7-
g++ $FUNCTOR_DIR/functors.cpp -c -fPIC -o $FUNCTOR_DIR/functors.o
7+
g++ $FUNCTOR_DIR/functors.cpp -c -fPIC -o $FUNCTOR_DIR/functors.o -I/home/dimo/.local/include
88
g++ -shared -o $FUNCTOR_DIR/libfunctors.so $FUNCTOR_DIR/functors.o

src/bin/cli.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
isExact
2222
} from "solc-typed-ast";
2323
import { analyze, buildDatalog, detect } from "../lib";
24-
import { SouffleCSVInstance } from "../lib/souffle/instance";
24+
import * as dl from "souffle.ts";
2525

2626
const pkg = require("../../package.json");
2727

@@ -306,8 +306,8 @@ async function main() {
306306
infer,
307307
"csv",
308308
options.dumpAnalyses
309-
)) as SouffleCSVInstance;
310-
const output = instance.results();
309+
)) as dl.SouffleCSVInstance;
310+
const output = await instance.allFacts();
311311
instance.release();
312312

313313
for (const analysis of options.dumpAnalyses) {

src/lib/detector.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import * as sol from "solc-typed-ast";
33
import { searchRecursive } from "./utils";
44
import { OutputRelations } from "./souffle";
55
import { DETECTORS_DIR } from "./detectors";
6-
import { Fact, FieldVal } from "./souffle/fact";
6+
import * as dl from "souffle.ts";
77

88
type SignatureArgs = Array<[string, string]>;
99
type ParsedSignature = [string, SignatureArgs];
10-
type SubstMap = Map<string, FieldVal>;
10+
type SubstMap = Map<string, dl.FieldVal>;
1111

1212
interface DetectorTemplate {
1313
fileName: string;
@@ -54,7 +54,7 @@ export function parseTemplateSignature(sig: string): ParsedSignature {
5454
return [name, args];
5555
}
5656

57-
function makeSubst(formals: SignatureArgs, fact: Fact): SubstMap {
57+
function makeSubst(formals: SignatureArgs, fact: dl.Fact): SubstMap {
5858
const res = new Map();
5959

6060
sol.assert(

src/lib/souffle/ast/declarations/adt.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/lib/souffle/ast/declarations/alias_type.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/lib/souffle/ast/declarations/component.ts

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/lib/souffle/ast/declarations/component_init.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/lib/souffle/ast/declarations/declaration.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)