Skip to content

Commit 38a4725

Browse files
authored
Fix TOC to handle old/abandoned rpt evidence gracefully (#73)
1 parent ce584ce commit 38a4725

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# [1.6.1](https://github.com/ComplianceAsCode/auditree-framework/releases/tag/v1.6.1)
2+
3+
- [FIXED] Table of contents now handles old/abandoned report evidence metadata appropriately.
4+
15
# [1.6.0](https://github.com/ComplianceAsCode/auditree-framework/releases/tag/v1.6.0)
26

37
- [ADDED] Check reports table of contents now appended to an evidence locker's README.

compliance/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
# limitations under the License.
1515
"""Compliance automation package."""
1616

17-
__version__ = '1.6.0'
17+
__version__ = '1.6.1'

compliance/report.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ def generate_toc(self, rpt_metadata):
120120
continue
121121
rpt_descr = meta['description'] or pathlib.Path(rpt).name
122122
rpt_url = self.locker.get_remote_location(rpt, False)
123-
check = meta['checks'][0].rsplit('.', 1).pop(0)
123+
check = meta.get('checks', ['N/A'])[0].rsplit('.', 1).pop(0)
124124
evidences = []
125-
for ev in meta['evidence']:
125+
for ev in meta.get('evidence', []):
126126
ev_path = pathlib.Path(ev['path'])
127127
ev_descr = ev['description'] or ev_path.name
128128
if not ev.get('partitions'):
@@ -151,13 +151,13 @@ def generate_toc(self, rpt_metadata):
151151
'from': ev['last_update']
152152
}
153153
)
154-
accreditations = self.controls.get_accreditations(check)
154+
accreditations = sorted(self.controls.get_accreditations(check))
155155
rpts.append(
156156
{
157157
'descr': rpt_descr,
158158
'url': rpt_url,
159159
'check': check,
160-
'accreditations': ', '.join(sorted(accreditations)),
160+
'accreditations': ', '.join(accreditations) or 'N/A',
161161
'from': meta['last_update'],
162162
'evidences': sorted(evidences, key=lambda ev: ev['descr'])
163163
}

0 commit comments

Comments
 (0)