Skip to content

Commit 53557db

Browse files
authored
Merge pull request #18800 from paldepind/generate-model-script
Sanitize path when generating MaD files
2 parents 02249af + 12a5766 commit 53557db

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

misc/scripts/models-as-data/generate_flow_model.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import subprocess
99
import sys
1010
import tempfile
11+
import re
1112

1213
def quote_if_needed(row):
1314
if row != "true" and row != "false":
@@ -52,8 +53,8 @@ def printHelp(self):
5253
--with-sources
5354
--with-summaries
5455
--with-neutrals
55-
--with-mixed-summaries (Experimental). May not be used in conjunction with --with-summaries.
56-
--with-mixed-neutrals (Experimental). Should only be used in conjunction with --with-mixed-summaries.
56+
--with-mixed-summaries. May not be used in conjunction with --with-summaries.
57+
--with-mixed-neutrals. Should only be used in conjunction with --with-mixed-summaries.
5758
--with-typebased-summaries (Experimental)
5859
If none of these flags are specified, all models are generated except for the type based models.
5960
@@ -65,7 +66,7 @@ def printHelp(self):
6566
$ python3 GenerateFlowModel.py /tmp/dbs/my_library_db --with-sinks my_directory
6667
6768
68-
Requirements: `codeql` should both appear on your path.
69+
Requirements: `codeql` should appear on your path.
6970
""")
7071

7172

@@ -211,7 +212,9 @@ def save(self, extensions, extension):
211212
extensions:
212213
{0}"""
213214
for entry in extensions:
214-
target = os.path.join(self.generatedFrameworks, entry + extension)
215+
# Replace problematic characters with dashes, and collapse multiple dashes.
216+
sanitizedEntry = re.sub(r'-+', '-', entry.replace('/', '-').replace(':', '-'))
217+
target = os.path.join(self.generatedFrameworks, sanitizedEntry + extension)
215218
with open(target, "w") as f:
216219
f.write(extensionTemplate.format(extensions[entry]))
217220
print("Models as data extensions written to " + target)

0 commit comments

Comments
 (0)