Merge pull request #11527 from michaelnebel/java/regeneratemodels

Java/C#: Delete old model generator scripts and update Java model re-generator script.
This commit is contained in:
Michael Nebel
2022-12-06 09:24:13 +01:00
committed by GitHub
7 changed files with 87 additions and 395 deletions

View File

@@ -1,15 +0,0 @@
#!/usr/bin/python3
import sys
import os.path
import subprocess
# Add Model as Data script directory to sys.path.
gitroot = subprocess.check_output(["git", "rev-parse", "--show-toplevel"]).decode("utf-8").strip()
madpath = os.path.join(gitroot, "misc/scripts/models-as-data/")
sys.path.append(madpath)
import generate_flow_model_extensions as model
language = "java"
model.Generator.make(language).run()

View File

@@ -5,19 +5,17 @@
from pathlib import Path
import json
import os
import requests
import shutil
import subprocess
import tempfile
import sys
defaultModelPath = "java/ql/lib/semmle/code/java/frameworks"
lgtmSlugToModelFile = {
# "apache/commons-beanutils": "apache/BeanUtilsGenerated.qll",
# "apache/commons-codec": "apache/CodecGenerated.qll",
# "apache/commons-lang": "apache/Lang3Generated.qll",
"apache/commons-io": "apache/IOGenerated.qll",
"apache/commons-io": "org.apache.commons.io",
}
@@ -36,13 +34,12 @@ def regenerateModel(lgtmSlug, extractedDb):
print("ERROR: slug " + lgtmSlug +
" is not mapped to a model file in script " + sys.argv[0])
sys.exit(1)
modelFile = defaultModelPath + "/" + lgtmSlugToModelFile[lgtmSlug]
modelFile = lgtmSlugToModelFile[lgtmSlug]
codeQlRoot = findGitRoot()
targetModel = codeQlRoot + "/" + modelFile
subprocess.check_call([codeQlRoot + "/java/ql/src/utils/model-generator/GenerateFlowModel.py",
"--with-summaries", "--with-sinks",
extractedDb, targetModel])
print("Regenerated " + targetModel)
"--with-summaries", "--with-sinks", "--with-negative-summaries",
extractedDb, modelFile])
print("Regenerated " + modelFile)
shutil.rmtree(tmpDir)