Skip to content

Commit 31e6106

Browse files
committed
STR53-C:
Result deduced from copy contructor in `getInitialContainerSize`
1 parent 08c7e25 commit 31e6106

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

.vscode/settings.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"sarif-viewer.connectToGithubCodeScanning": "off",
3+
"codeQL.cli.executablePath": "/Users/mauro/GitHub/coding-standards/codeql-bundle-20220908/codeql",
4+
"codeQL.runningQueries.numberOfThreads": 0,
5+
"codeQL.runningTests.numberOfThreads": 0,
6+
"codeQL.runningQueries.autoSave": true,
7+
"codeQL.runningQueries.debug": true,
8+
"files.associations": {
9+
"*.jq": "json",
10+
"*.py": "python",
11+
"*.expected": "csv (pipe)",
12+
"*.actual": "csv (pipe)",
13+
"*.qls": "yaml",
14+
"*.qcc": "cpp",
15+
"*.gcc": "cpp",
16+
"iosfwd": "cpp",
17+
"fstream": "cpp",
18+
"iostream": "cpp"
19+
}
20+
}

cpp/common/src/codingstandards/cpp/rules/containeraccesswithoutrangecheck/ContainerAccessWithoutRangeCheck.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,11 @@ class StringContainerConstructorCall extends ContainerConstructorCall {
185185
c.getParameter(1).getType() = stringInstantiation.getConstAllocatorReferenceType() and
186186
result = getArgument(0).getValue().length()
187187
or
188+
// from c-string copy constructor
189+
c.getNumberOfParameters() = 1 and
190+
c.getParameter(0).getType() = stringInstantiation.getValueType() and
191+
result = getArgument(0).getValue().length()
192+
or
188193
// Lower bound of an explicit size argument
189194
result = lowerBound(getInitialContainerSizeExpr().getFullyConverted())
190195
}

scripts/build_test_database.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
exit(1)
4848

4949
# get the codeql version
50-
res = subprocess.run(['codeql', 'version', '--format', 'json'], stdout=subprocess.PIPE)
50+
res = subprocess.run(['/Users/mauro/GitHub/coding-standards/codeql-bundle-20220908/codeql', 'version', '--format', 'json'], stdout=subprocess.PIPE)
5151
res_json = json.loads(res.stdout)
5252
CODEQL_VERSION=res_json["version"]
5353

@@ -61,10 +61,10 @@
6161

6262
elif LANGUAGE == "c":
6363
FILES = ' '.join([f for f in all_files if f.endswith('.c')])
64-
BUILD_COMMAND=f"clang -fsyntax-only {FILES}"
64+
BUILD_COMMAND=f"clang -fsyntax-only -I../../../../common/test/includes/custom-library {FILES}"
6565

6666
ITERATION=0
6767
while os.path.exists(f"databases/{RULE}+{ITERATION}@{CODEQL_VERSION}"):
6868
ITERATION = ITERATION + 1
6969

70-
os.system(f"codeql database create -l cpp -s {LANGUAGE}/{STANDARD}/test/rules/{RULE} --command=\"{BUILD_COMMAND}\" databases/{RULE}+{ITERATION}@{CODEQL_VERSION}")
70+
os.system(f"/Users/mauro/GitHub/coding-standards/codeql-bundle-20220908/codeql database create -l cpp -s {LANGUAGE}/{STANDARD}/test/rules/{RULE} --command=\"{BUILD_COMMAND}\" databases/{RULE}+{ITERATION}@{CODEQL_VERSION}")

0 commit comments

Comments
 (0)