cisagov / cyhy-core

Core code for Cyber Hygiene (CyHy)
Other
7 stars 9 forks source link

Verify that email addresses are valid before saving request documents #95

Closed jsf9k closed 5 months ago

jsf9k commented 5 months ago

šŸ—£ Description

This pull request modifies the code to verify that email addresses are valid before saving request documents.

šŸ’­ Motivation and context

Resolves #94.

šŸ§Ŗ Testing

I deployed this change to database1.prod-a.cyhy, exported a customer with cyhy-export, then tinkered with the email addresses and attempted to import said customer via cyhy-import. WHen I used an valid email address the import was successful and when I used an invalid email address the import failed with an error similar to the following:

$ cyhy-import --force REDACTED.json
Traceback (most recent call last):
  File "/usr/local/bin/cyhy-import", line 186, in <module>
    main()
  File "/usr/local/bin/cyhy-import", line 177, in main
    success = import_file(db, args["FILE"], args["--force"], args["--init-stage"])
  File "/usr/local/bin/cyhy-import", line 158, in import_file
    return import_request(db, request, filename, force, init_stage)
  File "/usr/local/bin/cyhy-import", line 145, in import_request
    doc.save()
  File "/usr/local/lib/python2.7/dist-packages/cyhy/db/database.py", line 1310, in save
    raise ValueError(email_address + " is not a valid email address")
ValueError: redacted@@redacted.com is not a valid email address

āœ… Pre-approval checklist

āœ… Post-merge checklist

jsf9k commented 5 months ago

I'll wait for @mcdonnnj's review before merging this one.