Skip to content

Commit

Permalink
Fix datetime for older Python
Browse files Browse the repository at this point in the history
  • Loading branch information
Mab879 committed Sep 27, 2023
1 parent 71b4588 commit fac076c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion utils/create_scap_delta_tailoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,13 @@ def setup_tailoring_profile(profile_id, profile_root):
setup_tailoring_profile.__annotations__ = {'profile_id': str, 'profile_root': ET.Element}


def _get_datetime():
try:
return datetime.datetime.now(datetime.UTC).isoformat()
except AttributeError:
return datetime.datetime.utcnow().isoformat()


def create_tailoring(args):
benchmark_root = ET.parse(args.manual).getroot()
known_rules = get_implemented_stigs(args.product, args.root, args.build_config_yaml,
Expand All @@ -179,7 +186,7 @@ def create_tailoring(args):

tailoring_root = ET.Element('xccdf-1.2:Tailoring')
version = ET.SubElement(tailoring_root, 'xccdf-1.2:version',
attrib={'time': datetime.datetime.now(datetime.UTC).isoformat()})
attrib={'time': _get_datetime()})
version.text = '1'
tailoring_root.set('id', args.tailoring_id)
tailoring_root.append(tailoring_profile)
Expand Down

0 comments on commit fac076c

Please sign in to comment.