Skip to content
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
1 change: 1 addition & 0 deletions docker.env
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ POSTGRES_PASSWORD=vulnerablecode

VULNERABLECODE_DB_HOST=db
VULNERABLECODE_STATIC_ROOT=/var/vulnerablecode/static/
SECRET_KEY=JASCFGIBAaijhsbdfabIABFDGIABF!
32 changes: 32 additions & 0 deletions vulntotal/tests/test_data/vulnerablecode/RecordID_to_UUID.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import json
import uuid

with open('advisory.json', 'r') as file:
data = json.load(file)

def replace_ids_with_uuids(data):
def replace_in_url(url):
base_url, record_id = url.rsplit('/', 1)
new_uuid = str(uuid.uuid4())
return f"{base_url}/{new_uuid}"

if isinstance(data, list):
for item in data:
item['url'] = replace_in_url(item['url'])

for package in item.get('fixed_packages', []):
package['url'] = replace_in_url(package['url'])

for package in item.get('affected_packages', []):
package['url'] = replace_in_url(package['url'])
else:
print("Data is not a list as expected.")

return data

updated_data = replace_ids_with_uuids(data)

with open('advisory.json', 'w') as file:
json.dump(updated_data, file, indent=4)

print("URLs have been updated.")
Loading