Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First commits to create cyhy-db #5

Draft
wants to merge 101 commits into
base: develop
Choose a base branch
from
Draft

First commits to create cyhy-db #5

wants to merge 101 commits into from

Conversation

felddy
Copy link
Member

@felddy felddy commented Sep 25, 2024

🗣 Description

This PR contains the initial functionality of the cyhy-db module, which provides a object model for accessing the various document collections in a Cyber Hygiene database.

This PR also includes an assortment of unit tests, though more testing will likely be added later.

💭 Motivation and context

We have two main motivations here:

  1. To migrate from our legacy data model which was built on outdated Python 2 libraries to a more modern model that uses Python 3 (hello Beanie!)
  2. To break the CyHy database model out into its own repository and module thus making it more testable and maintainable.

🧪 Testing

All unit tests currently pass in pytest. This code has also been partially tested by its use in the cyhy-kevsync module (initial PR coming soon).

✅ Pre-approval checklist

  • This PR has an informative and human-readable title.
  • Changes are limited to a single goal - eschew scope creep!
  • All future TODOs are captured in issues, which are referenced
    in code comments.
  • All relevant type-of-change labels have been added.
  • I have read the CONTRIBUTING document.
  • These code changes follow cisagov code standards.
  • All relevant repo and/or project documentation has been updated
    to reflect the changes in this PR.
  • Tests have been added and/or modified to cover the changes in this PR.
  • All new and existing tests pass.

✅ Pre-merge checklist

  • Finalize version.

✅ Post-merge checklist

  • Create a release.
  • Create (or move) v1 tag that points to new release.

Delete example package and files

Update Python version to 3.12 in build workflows

Update package name and description in setup.py

Update dependencies in setup.py
Add comments to severity calculation.
This commit refactors the CVE model and test in the `cyhy_db` package. The changes include:
- Replacing the `odmantic` library with `mongoengine` for the model definition.
- Updating the field types and constraints in the CVE model.
- Removing the `calculate_severity` method and integrating the severity calculation directly in the `save` method.
- Updating the test cases to reflect the changes in the model.
We aren't using Random() for the purposes of cryptography here, so we can safely ignore these warnings.
@felddy felddy added documentation This issue or pull request improves or adds to documentation hacktoberfest-accepted Pull request that should count toward Hacktoberfest participation improvement This issue or pull request will add or improve functionality, maintainability, or ease of use labels Sep 25, 2024
@felddy felddy self-assigned this Sep 25, 2024
@coveralls
Copy link

coveralls commented Sep 25, 2024

Pull Request Test Coverage Report for Build 11164912521

Details

  • 546 of 546 (100.0%) changed or added relevant lines in 22 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 10273838208: 0.0%
Covered Lines: 547
Relevant Lines: 547

💛 - Coveralls

dav3r and others added 16 commits October 1, 2024 16:33
This is primarily because pymongo DEBUG level logging is extremely verbose and should only be enabled when needed.

Co-authored-by: Mark Feldhousen <mark.feldhousen@gwe.cisa.dhs.gov>
Co-authored-by: Mark Feldhousen <mark.feldhousen@gwe.cisa.dhs.gov>
Co-authored-by: Mark Feldhousen <mark.feldhousen@gwe.cisa.dhs.gov>
Co-authored-by: Mark Feldhousen <mark.feldhousen@gwe.cisa.dhs.gov>
This field now accepts either a string representing the time (%H:%M:%S) or a datetime.time object, which is stored in the database as a string in %H:%M:%S format.

This also improves our input checking so that invalid times (e.g. 34:45:56) can no longer be added.

Co-authored-by: Mark Feldhousen <mark.feldhousen@gwe.cisa.dhs.gov>
Also, remove some commented-out code that is no longer needed.

Co-authored-by: Mark Feldhousen <mark.feldhousen@gwe.cisa.dhs.gov>
Co-authored-by: Mark Feldhousen <mark.feldhousen@gwe.cisa.dhs.gov>
Co-authored-by: Mark Feldhousen <mark.feldhousen@gwe.cisa.dhs.gov>
…s option

Co-authored-by: Mark Feldhousen <mark.feldhousen@gwe.cisa.dhs.gov>
Co-authored-by: Mark Feldhousen <mark.feldhousen@gwe.cisa.dhs.gov>
dav3r and others added 4 commits October 2, 2024 17:31
Co-authored-by: Mark Feldhousen <mark.feldhousen@gwe.cisa.dhs.gov>
…include the same indexes as ScanDoc

Co-authored-by: Mark Feldhousen <mark.feldhousen@gwe.cisa.dhs.gov>
Co-authored-by: Mark Feldhousen <mark.feldhousen@gwe.cisa.dhs.gov>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation This issue or pull request improves or adds to documentation hacktoberfest-accepted Pull request that should count toward Hacktoberfest participation improvement This issue or pull request will add or improve functionality, maintainability, or ease of use
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

3 participants