Skip to content
Merged
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
11 changes: 10 additions & 1 deletion jenkins/scripts/pulse_in_pipeline_scanning/utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ def load_json(path):
return json.load(f)


def check_license(result):
license = result["license"]
is_nvidia_proprietary = result["isProprietary"] and "nvidia" in license.lower()
return result["isPermissive"] or is_nvidia_proprietary


def is_permissive(licenses: list, license_check_token: str) -> dict:
"""Checks permissiveness for a list of license IDs in a single API call.

Expand All @@ -31,7 +37,10 @@ def is_permissive(licenses: list, license_check_token: str) -> dict:
if response:
resp = response.json()
if resp["success"]:
return {lic: result["isPermissive"] for lic, result in zip(licenses, resp["data"])}
if len(resp["data"]) != len(licenses):
print("License API returned mismatched result count", file=sys.stderr)
continue
return {result["license"]: check_license(result) for result in resp["data"]}
print(json.dumps(resp), file=sys.stderr)
else:
print(f"HTTP {response.status_code}", file=sys.stderr)
Expand Down
Loading