Added support for external repository file links

This commit is contained in:
Michael Chen 2022-12-13 15:48:29 +01:00
parent ca6fee127c
commit b4f5e3ebd4
Signed by: cnml
GPG Key ID: 5845BF3F82D5F629
2 changed files with 5 additions and 1 deletions

View File

@ -218,6 +218,7 @@ from typing import TypedDict
class Artifact(TypedDict):
file: str
lines: NotRequired[list[int]]
repository: NotRequired[str]
class SecurityRule(TypedDict):
status: str
@ -253,6 +254,8 @@ properties:
properties:
file:
type: string
repository:
type: string
lines:
type: array
items:
@ -306,7 +309,7 @@ rule_names = {
def artifact_to_string(info: ModelInformation, artifact: Artifact):
file = Path(artifact['file'])
filename = file.name
file_url = f"https://github.com/{info['slug']}/blob/{info.get('branch', 'master')}/{artifact['file']}"
file_url = f"https://github.com/{artifact.get('repository', info['slug'])}/blob/{info.get('branch', 'master')}/{artifact['file']}"
lines = artifact.get("lines")
if lines is None:
return f"- {filename}: [File]({file_url})"

View File

@ -27,6 +27,7 @@
"type": "object",
"additionalProperties": false,
"properties": {
"repository": { "type": "string" },
"file": { "type": "string" },
"lines": { "type": "array", "items": { "type": "integer" } }
},