vunnel icon indicating copy to clipboard operation
vunnel copied to clipboard

chore: replace frequenty used dict literals with data classes

Open willmurphyscode opened this issue 1 year ago • 1 comments

For example:

https://github.com/anchore/vunnel/blob/c615dcae89ec4b84d7a51a62d77c69a6a496af9e/src/vunnel/utils/vulnerability.py#L16-L27 gets copy.deepcopy-ed around a lot, as a template for a dict literal. The code would be cleaner and have more useful type hinting if this were replaced with a data class.

Examples of copying https://github.com/anchore/vunnel/blob/c615dcae89ec4b84d7a51a62d77c69a6a496af9e/src/vunnel/utils/oval_parser.py#L160-L170

and https://github.com/anchore/vunnel/blob/c615dcae89ec4b84d7a51a62d77c69a6a496af9e/src/vunnel/providers/wolfi/parser.py#L103-L109

willmurphyscode avatar Jul 30 '24 00:07 willmurphyscode

We want to make sure that whatever solution we use is not vulnerable to crashing because a field is added, so maybe skipping straight to data classes is the wrong approach. I'll research some additional approaches.

willmurphyscode avatar Aug 01 '24 20:08 willmurphyscode