Skip to content

Commit 0bab5ee

Browse files
committed
fix: Changed used lines to be a joined by ',' str instead of a list
1 parent 778c25e commit 0bab5ee

File tree

6 files changed

+24
-24
lines changed

6 files changed

+24
-24
lines changed

app/utils/code_analyzer/codes/cs_code_analyzer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ async def cs_get_used_artifacts(
2828
if not search(r"using\s", line):
2929
for (artifact, _type, source) in used_artifacts:
3030
if artifact in line:
31-
used_artifacts[(artifact, _type, source)].append(current_line)
31+
used_artifacts[(artifact, _type, source)].append(str(current_line))
3232
current_line += 1
3333
used_artifacts = {
3434
(artifact, _type, source): lines
@@ -38,7 +38,7 @@ async def cs_get_used_artifacts(
3838
result = []
3939
groups_by_name_type = {}
4040
for (artifact_name, artifact_type, source), used_in_lines in used_artifacts.items():
41-
groups_by_name_type.setdefault((artifact_name, artifact_type, used_in_lines), []).append(source)
41+
groups_by_name_type.setdefault((artifact_name, artifact_type, ",".join(used_in_lines)), []).append(source)
4242
for (artifact_name, artifact_type, used_in_lines), sources in groups_by_name_type.items():
4343
result.append({
4444
"artifact_name": artifact_name,
@@ -54,8 +54,8 @@ async def get_child_artifacts(
5454
code: str,
5555
cve_description: str,
5656
affected_artefacts: dict[str, list[str]]
57-
) -> dict[tuple[str, str, str], list[int]]:
58-
used_artifacts: dict[tuple[str, str, str], list[int]] = {}
57+
) -> dict[tuple[str, str, str], list[str]]:
58+
used_artifacts: dict[tuple[str, str, str], list[str]] = {}
5959
patterns = [
6060
(rf"{parent}\.[^\(\)\s:;]+", "split_by_dot"),
6161
(rf"using\s+{parent}\s*;\s*{{[^}}]+}}", "split_by_braces"),

app/utils/code_analyzer/codes/java_code_analyzer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ async def java_get_used_artifacts(
2828
if "import" not in line:
2929
for (artifact, _type, source) in used_artifacts:
3030
if artifact in line:
31-
used_artifacts[(artifact, _type, source)].append(current_line)
31+
used_artifacts[(artifact, _type, source)].append(str(current_line))
3232
current_line += 1
3333
used_artifacts = {
3434
(artifact, _type, source): lines
@@ -38,7 +38,7 @@ async def java_get_used_artifacts(
3838
result = []
3939
groups_by_name_type = {}
4040
for (artifact_name, artifact_type, source), used_in_lines in used_artifacts.items():
41-
groups_by_name_type.setdefault((artifact_name, artifact_type, used_in_lines), []).append(source)
41+
groups_by_name_type.setdefault((artifact_name, artifact_type, ",".join(used_in_lines)), []).append(source)
4242
for (artifact_name, artifact_type, used_in_lines), sources in groups_by_name_type.items():
4343
result.append({
4444
"artifact_name": artifact_name,
@@ -54,8 +54,8 @@ async def get_child_artifacts(
5454
code: str,
5555
cve_description: str,
5656
affected_artefacts: dict[str, list[str]]
57-
) -> dict[tuple[str, str, str], list[int]]:
58-
used_artifacts: dict[tuple[str, str, str], list[int]] = {}
57+
) -> dict[tuple[str, str, str], list[str]]:
58+
used_artifacts: dict[tuple[str, str, str], list[str]] = {}
5959
patterns = [
6060
(rf"{parent}\.[^\(\)\s:;]+", "split_by_dot"),
6161
(rf"import\s+{parent}\.[^\(\)\s:;]+;", "split_by_import"),

app/utils/code_analyzer/codes/js_ts_code_analyzer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ async def js_ts_get_used_artifacts(
2828
if not search(r"import\s|require\(", line):
2929
for (artifact, _type, source) in used_artifacts:
3030
if artifact in line:
31-
used_artifacts[(artifact, _type, source)].append(current_line)
31+
used_artifacts[(artifact, _type, source)].append(str(current_line))
3232
current_line += 1
3333
used_artifacts = {
3434
(artifact, _type, source): lines
@@ -38,7 +38,7 @@ async def js_ts_get_used_artifacts(
3838
result = []
3939
groups_by_name_type = {}
4040
for (artifact_name, artifact_type, source), used_in_lines in used_artifacts.items():
41-
groups_by_name_type.setdefault((artifact_name, artifact_type, used_in_lines), []).append(source)
41+
groups_by_name_type.setdefault((artifact_name, artifact_type, ",".join(used_in_lines)), []).append(source)
4242
for (artifact_name, artifact_type, used_in_lines), sources in groups_by_name_type.items():
4343
result.append({
4444
"artifact_name": artifact_name,
@@ -54,8 +54,8 @@ async def get_child_artifacts(
5454
code: str,
5555
cve_description: str,
5656
affected_artefacts: dict[str, list[str]]
57-
) -> dict[tuple[str, str, str], list[int]]:
58-
used_artifacts: dict[tuple[str, str, str], list[int]] = {}
57+
) -> dict[tuple[str, str, str], list[str]]:
58+
used_artifacts: dict[tuple[str, str, str], list[str]] = {}
5959
patterns = [
6060
(rf"{parent}\.[^\(\)\s:;]+", "split_by_dot"),
6161
(rf"import\s+{{[^}}]+}}\s+from\s+['\"]{parent}['\"]", "split_by_braces"),

app/utils/code_analyzer/codes/py_code_analyzer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async def py_get_used_artifacts(
3030
if "import" not in line:
3131
for (artifact, _type, source) in used_artifacts:
3232
if artifact in line:
33-
used_artifacts[(artifact, _type, source)].append(current_line)
33+
used_artifacts[(artifact, _type, source)].append(str(current_line))
3434
current_line += 1
3535
used_artifacts = {
3636
(artifact, _type, source): lines
@@ -40,7 +40,7 @@ async def py_get_used_artifacts(
4040
result = []
4141
groups_by_name_type = {}
4242
for (artifact_name, artifact_type, source), used_in_lines in used_artifacts.items():
43-
groups_by_name_type.setdefault((artifact_name, artifact_type, used_in_lines), []).append(source)
43+
groups_by_name_type.setdefault((artifact_name, artifact_type, ",".join(used_in_lines)), []).append(source)
4444
for (artifact_name, artifact_type, used_in_lines), sources in groups_by_name_type.items():
4545
result.append({
4646
"artifact_name": artifact_name,
@@ -58,8 +58,8 @@ async def get_child_artifacts(
5858
cve_description: str,
5959
affected_artefacts: dict[str, list[str]],
6060
visited: set[str]
61-
) -> dict[tuple[str, str, str], list[int]]:
62-
used_artifacts: dict[tuple[str, str, str], list[int]] = {}
61+
) -> dict[tuple[str, str, str], list[str]]:
62+
used_artifacts: dict[tuple[str, str, str], list[str]] = {}
6363
patterns = []
6464
for target in [name, import_name]:
6565
escaped = escape(target)

app/utils/code_analyzer/codes/rb_code_analyzer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async def rb_get_used_artifacts(
3030
if not search(r"require|require_relative|include|extend", line):
3131
for (artifact, _type, source) in used_artifacts:
3232
if artifact in line:
33-
used_artifacts[(artifact, _type, source)].append(current_line)
33+
used_artifacts[(artifact, _type, source)].append(str(current_line))
3434
current_line += 1
3535
used_artifacts = {
3636
(artifact, _type, source): lines
@@ -40,7 +40,7 @@ async def rb_get_used_artifacts(
4040
result = []
4141
groups_by_name_type = {}
4242
for (artifact_name, artifact_type, source), used_in_lines in used_artifacts.items():
43-
groups_by_name_type.setdefault((artifact_name, artifact_type, used_in_lines), []).append(source)
43+
groups_by_name_type.setdefault((artifact_name, artifact_type, ",".join(used_in_lines)), []).append(source)
4444
for (artifact_name, artifact_type, used_in_lines), sources in groups_by_name_type.items():
4545
result.append({
4646
"artifact_name": artifact_name,
@@ -58,8 +58,8 @@ async def get_child_artifacts(
5858
cve_description: str,
5959
affected_artefacts: dict[str, dict[str, list[str]]],
6060
visited: set[str]
61-
) -> dict[tuple[str, str, str], list[int]]:
62-
used_artifacts: dict[tuple[str, str, str], list[int]] = {}
61+
) -> dict[tuple[str, str, str], list[str]]:
62+
used_artifacts: dict[tuple[str, str, str], list[str]] = {}
6363
patterns = []
6464
for target in [name, gem_name]:
6565
escaped = escape(target)

app/utils/code_analyzer/codes/rs_code_analyzer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ async def rs_get_used_artifacts(
2828
if not search(r"extern crate\s|use\s", line):
2929
for (artifact, _type, source) in used_artifacts:
3030
if artifact in line:
31-
used_artifacts[(artifact, _type, source)].append(current_line)
31+
used_artifacts[(artifact, _type, source)].append(str(current_line))
3232
current_line += 1
3333
used_artifacts = {
3434
(artifact, _type, source): lines
@@ -38,7 +38,7 @@ async def rs_get_used_artifacts(
3838
result = []
3939
groups_by_name_type = {}
4040
for (artifact_name, artifact_type, source), used_in_lines in used_artifacts.items():
41-
groups_by_name_type.setdefault((artifact_name, artifact_type, used_in_lines), []).append(source)
41+
groups_by_name_type.setdefault((artifact_name, artifact_type, ",".join(used_in_lines)), []).append(source)
4242
for (artifact_name, artifact_type, used_in_lines), sources in groups_by_name_type.items():
4343
result.append({
4444
"artifact_name": artifact_name,
@@ -54,8 +54,8 @@ async def get_child_artifacts(
5454
code: str,
5555
cve_description: str,
5656
affected_artefacts: dict[str, list[str]]
57-
) -> dict[tuple[str, str, str], list[int]]:
58-
used_artifacts: dict[tuple[str, str, str], list[int]] = {}
57+
) -> dict[tuple[str, str, str], list[str]]:
58+
used_artifacts: dict[tuple[str, str, str], list[str]] = {}
5959
patterns = [
6060
(rf"{parent}::[^\(\)\s:;]+", "split_by_double_colon"),
6161
(rf"use\s+{parent}::{{[^}}]+}};", "split_by_braces"),

0 commit comments

Comments
 (0)