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

Stop iterating maps in catalogers #2405

Closed
3 tasks
willmurphyscode opened this issue Dec 7, 2023 · 0 comments · Fixed by #2553
Closed
3 tasks

Stop iterating maps in catalogers #2405

willmurphyscode opened this issue Dec 7, 2023 · 0 comments · Fixed by #2553
Assignees
Labels
bug Something isn't working
Milestone

Comments

@willmurphyscode
Copy link
Contributor

What happened:

We've seen a couple places in syft where we iterate over a map during cataloging. However, the order of map iteration in go is non-deterministic.

When iterating over a map with a range loop, the iteration order is not specified and is not guaranteed to be the same from one iteration to the next. If you require a stable iteration order you must maintain a separate data structure that specifies that order.

This is an overall tracking issue for places where syft catalogers accidentally assume that iterating over a map is deterministic. For example, sometimes we have a map and we iterate over it with a for loop looking for candidates that match some criteria. If more than one candidate matches the criteria, which candidate is selected will not be stable on repeated runs on syft with the same input, which can surprise users.

See #2170 for an example of fixing a narrow case of this behavior.

What you expected to happen:

Syft's output should be deterministic for a given input.

List of places we're iterating a map in syft at cataloging time

@willmurphyscode willmurphyscode added the bug Something isn't working label Dec 7, 2023
@wagoodman wagoodman added this to the Syft 1.0 milestone Jan 25, 2024
@wagoodman wagoodman changed the title tracking issue: stop iterating maps in catalogers Stop iterating maps in catalogers Jan 31, 2024
@wagoodman wagoodman self-assigned this Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants