Skip to content

Commit cd5c0be

Browse files
authored
Merge pull request github#11527 from michaelnebel/java/regeneratemodels
Java/C#: Delete old model generator scripts and update Java model re-generator script.
2 parents b171dc9 + 19db8e5 commit cd5c0be

File tree

7 files changed

+87
-395
lines changed

7 files changed

+87
-395
lines changed

.github/workflows/mad_modelDiff.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
branches:
1212
- main
1313
paths:
14-
- "java/ql/src/utils/model-generator/**/*.*"
14+
# - "java/ql/src/utils/model-generator/**/*.*"
1515
- ".github/workflows/mad_modelDiff.yml"
1616

1717
permissions:
@@ -61,8 +61,8 @@ jobs:
6161
DATABASE=$2
6262
cd codeql-$QL_VARIANT
6363
SHORTNAME=`basename $DATABASE`
64-
python java/ql/src/utils/model-generator/GenerateFlowModel.py --with-summaries --with-sinks $DATABASE $MODELS/${SHORTNAME}.qll
65-
mv $MODELS/${SHORTNAME}.qll $MODELS/${SHORTNAME}Generated_${QL_VARIANT}.qll
64+
python java/ql/src/utils/model-generator/GenerateFlowModel.py --with-summaries --with-sinks $DATABASE $MODELS/${SHORTNAME}.model.yml
65+
mv $MODELS/${SHORTNAME}.model.yml $MODELS/${SHORTNAME}Generated_${QL_VARIANT}.model.yml
6666
cd ..
6767
}
6868
@@ -85,16 +85,16 @@ jobs:
8585
set -x
8686
MODELS=`pwd`/tmp-models
8787
ls -1 tmp-models/
88-
for m in $MODELS/*_main.qll ; do
88+
for m in $MODELS/*_main.model.yml ; do
8989
t="${m/main/"pr"}"
9090
basename=`basename $m`
91-
name="diff_${basename/_main.qll/""}"
91+
name="diff_${basename/_main.model.yml/""}"
9292
(diff -w -u $m $t | diff2html -i stdin -F $MODELS/$name.html) || true
9393
done
9494
- uses: actions/upload-artifact@v3
9595
with:
9696
name: models
97-
path: tmp-models/*.qll
97+
path: tmp-models/*.model.yml
9898
retention-days: 20
9999
- uses: actions/upload-artifact@v3
100100
with:

.github/workflows/mad_regenerate-models.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
java/ql/src/utils/model-generator/RegenerateModels.py "${SLUG}" dbs/${SHORTNAME}
5454
- name: Stage changes
5555
run: |
56-
find java -name "*.qll" -print0 | xargs -0 git add
56+
find java -name "*.model.yml" -print0 | xargs -0 git add
5757
git status
5858
git diff --cached > models.patch
5959
- uses: actions/upload-artifact@v3

csharp/ql/src/utils/model-generator/GenerateFlowModelExtensions.py

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

java/ql/src/utils/model-generator/GenerateFlowModelExtensions.py

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

java/ql/src/utils/model-generator/RegenerateModels.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,17 @@
55
from pathlib import Path
66
import json
77
import os
8-
import requests
98
import shutil
109
import subprocess
1110
import tempfile
1211
import sys
1312

1413

15-
defaultModelPath = "java/ql/lib/semmle/code/java/frameworks"
1614
lgtmSlugToModelFile = {
1715
# "apache/commons-beanutils": "apache/BeanUtilsGenerated.qll",
1816
# "apache/commons-codec": "apache/CodecGenerated.qll",
1917
# "apache/commons-lang": "apache/Lang3Generated.qll",
20-
"apache/commons-io": "apache/IOGenerated.qll",
18+
"apache/commons-io": "org.apache.commons.io",
2119
}
2220

2321

@@ -36,13 +34,12 @@ def regenerateModel(lgtmSlug, extractedDb):
3634
print("ERROR: slug " + lgtmSlug +
3735
" is not mapped to a model file in script " + sys.argv[0])
3836
sys.exit(1)
39-
modelFile = defaultModelPath + "/" + lgtmSlugToModelFile[lgtmSlug]
37+
modelFile = lgtmSlugToModelFile[lgtmSlug]
4038
codeQlRoot = findGitRoot()
41-
targetModel = codeQlRoot + "/" + modelFile
4239
subprocess.check_call([codeQlRoot + "/java/ql/src/utils/model-generator/GenerateFlowModel.py",
43-
"--with-summaries", "--with-sinks",
44-
extractedDb, targetModel])
45-
print("Regenerated " + targetModel)
40+
"--with-summaries", "--with-sinks", "--with-negative-summaries",
41+
extractedDb, modelFile])
42+
print("Regenerated " + modelFile)
4643
shutil.rmtree(tmpDir)
4744

4845

0 commit comments

Comments
 (0)