|
25 | 25 | with open(args.output_file, 'w') as csv_file:
|
26 | 26 | columns = [
|
27 | 27 | 'component',
|
28 |
| - 'component modified', |
29 | 28 | 'file path',
|
30 | 29 | 'file name',
|
31 | 30 | 'archive context',
|
32 | 31 | 'usage(s)',
|
33 | 32 | 'license(s)',
|
34 |
| - 'match type(s)', |
35 |
| - 'scan (code location)' |
| 33 | + 'source', |
| 34 | + 'origin(s)', |
| 35 | + 'origin_id(s)', |
| 36 | + 'copyright' |
36 | 37 | ]
|
37 | 38 | writer = csv.DictWriter(csv_file, fieldnames=columns)
|
38 | 39 | writer.writeheader()
|
|
45 | 46 | for matched_file_info in component_info.get('matched_files', []):
|
46 | 47 | row = {
|
47 | 48 | 'component': component,
|
48 |
| - 'component modified': component_info['bom_component_info'].get('componentModified', None), |
49 | 49 | 'file path': matched_file_info['filePath']['path'],
|
50 | 50 | 'file name': matched_file_info['filePath']['fileName'],
|
51 | 51 | 'archive context': matched_file_info['filePath']['archiveContext'],
|
52 | 52 | 'usage(s)': ",".join(matched_file_info['usages']),
|
53 | 53 | 'license(s)': ",".join([l['licenseDisplay'] for l in component_info['bom_component_info']['licenses']]),
|
54 |
| - 'match type(s)': ",".join(component_info['bom_component_info']['matchTypes']), |
55 |
| - 'scan (code location)': matched_file_info.get('scan', {}).get('name', 'unknown') |
| 54 | + 'source': 'customers source', |
| 55 | + 'origin(s)': ",".join([o['externalNamespace'] for o in component_info['bom_component_info']['origins']]), |
| 56 | + 'origin_id(s)': ",".join([o.get('externalId', "") for o in component_info['bom_component_info']['origins']]), |
| 57 | + 'copyright': None, |
56 | 58 | }
|
57 | 59 | writer.writerow(row)
|
58 | 60 |
|
| 61 | + for origin in component_info.get('all_origin_details', []): |
| 62 | + for license in origin.get('file_licenses_fuzzy', []): |
| 63 | + # import pdb; pdb.set_trace() |
| 64 | + row = { |
| 65 | + 'component': component, |
| 66 | + 'file path': license['path'], |
| 67 | + 'file name': os.path.basename(license['path']), |
| 68 | + 'archive context': None, |
| 69 | + 'usage(s)': None, |
| 70 | + 'license(s)': license['licenseGroupName'], |
| 71 | + 'source': 'KB', |
| 72 | + 'origin(s)': origin.get('originName'), |
| 73 | + 'origin_id(s)': origin.get('originId'), |
| 74 | + 'copyright': None |
| 75 | + } |
| 76 | + writer.writerow(row) |
| 77 | + |
| 78 | + for copyright in origin.get('file_copyrights', []): |
| 79 | + # import pdb; pdb.set_trace() |
| 80 | + row = { |
| 81 | + 'component': component, |
| 82 | + 'file path': copyright['path'], |
| 83 | + 'file name': os.path.basename(copyright['path']), |
| 84 | + 'archive context': None, |
| 85 | + 'usage(s)': None, |
| 86 | + 'license(s)': None, |
| 87 | + 'source': 'KB', |
| 88 | + 'origin(s)': origin.get('originName'), |
| 89 | + 'origin_id(s)': origin.get('originId'), |
| 90 | + 'copyright': copyright['matchData'].replace('\n', ''), |
| 91 | + } |
| 92 | + writer.writerow(row) |
| 93 | + |
| 94 | + |
59 | 95 | if args.un_matched_files:
|
60 | 96 | for un_matched_file in origin_info.get('un_matched_files'):
|
61 | 97 | uri = urllib.parse.unquote(un_matched_file['uri'])
|
|
0 commit comments