Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@mdnfiras
Copy link
Contributor

related: #1087

This PR solves this comment from the previously mentioned issue.

trivy-dojo-report-operator's VulnerabilityReport resources can get very big and cause issues. Having the ability to remove a couple of fields from the diff solves it.

Acknowledgement: Thanks to @baracoder for suggesting the core idea behind this approach!

Copy link
Owner

@nolar nolar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! The functionality might be helpful indeed. But it is better to use the existing routines to manage the dicts and fields uniformly with the rest of the framework.

@mdnfiras mdnfiras requested a review from nolar December 13, 2025 20:08
'i': 'j',
}
})
storage = cls(ignored_fields=['a.b', 'a.e.f.g', 'h', 'k.l.m'])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for the record: a.e.f.g is not a field, only a.e.f is β€” so it is an extra test for the removal of a non-existent field, the same as k.l.m.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes a.e.f.g is technically not a field, but this one in particular causes dicts.remove to throw a TypeError exception because a.e.f is a field but does not support item deletion, hence the extra test.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Makes sense, indeed.


def __init__(self, ignored_fields: Iterable[dicts.FieldSpec] | None = None) -> None:
super().__init__()
self.ignored_fields = list(ignored_fields or []) # materialize the iterable
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: I've added this materialization here, so that depletable iterables would persist and be reusable across multiple runs. I hope nobody uses generators (both expressions & functions) in this context, but just in case.

@nolar nolar added the enhancement New feature or request label Dec 19, 2025
@nolar nolar merged commit fc9c654 into nolar:main Dec 19, 2025
24 of 25 checks passed
@nolar
Copy link
Owner

nolar commented Dec 19, 2025

Released as 1.39.1. Thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants