Skip to content

Orlando/sarif line number #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion socketsecurity/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__author__ = 'socket.dev'
__version__ = '1.0.44'
__version__ = '1.0.45'
13 changes: 7 additions & 6 deletions socketsecurity/core/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ def find_line_in_file(packagename: str, packageversion: str, manifest_file: str)
needle_key = f'"{found_key}":' # e.g. "node_modules/axios":
needle_version = f'"version": "{packageversion}"'
lines = raw_text.splitlines()
best_line = -1
best_line = 1

snippet = None

for i, line in enumerate(lines, start=1):
Expand All @@ -97,10 +98,10 @@ def find_line_in_file(packagename: str, packageversion: str, manifest_file: str)
else:
return 1, f'"{found_key}": {found_info}'
else:
return -1, f"{packagename} {packageversion} (not found in {manifest_file})"
return 1, f"{packagename} {packageversion} (not found in {manifest_file})"

except (FileNotFoundError, json.JSONDecodeError):
return -1, f"Error reading {manifest_file}"
return 1, f"Error reading {manifest_file}"

# ----------------------------------------------------
# 2) Text-based / line-based manifests
Expand Down Expand Up @@ -148,11 +149,11 @@ def find_line_in_file(packagename: str, packageversion: str, manifest_file: str)
return line_number, line_content.strip()

except FileNotFoundError:
return -1, f"{manifest_file} not found"
return 1, f"{manifest_file} not found"
except Exception as e:
return -1, f"Error reading {manifest_file}: {e}"
return 1, f"Error reading {manifest_file}: {e}"

return -1, f"{packagename} {packageversion} (not found)"
return 1, f"{packagename} {packageversion} (not found)"

@staticmethod
def create_security_comment_sarif(diff: Diff) -> dict:
Expand Down
Loading