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

Container Scanning: Adds Os Release Information Parsers #1001

Merged
merged 7 commits into from
Jul 27, 2022

Conversation

meghfossa
Copy link
Contributor

Overview

This PR adds Os Release parser as part of container scanning scaffolding works.

Acceptance criteria

  • Can parse os info from container/linux image

Testing plan

I have added unit tests. As native container scanning is not configured E/E it cannot be tested manually yet.

Risks

N/A

References

https://fossa.atlassian.net/browse/ANE-284

Checklist

  • I added tests for this PR's change (or explained in the PR description why tests don't make sense).
  • If this PR introduced a user-visible change, I added documentation into docs/.
  • If this change is externally visible, I updated Changelog.md. If this PR did not mark a release, I added my changes into an # Unreleased section at the top.
  • If I made changes to .fossa.yml or fossa-deps.{json.yml}, I updated docs/references/files/*.schema.json. You may also need to update these if you have added/removed new dependency type (e.g. pip) or analysis target type (e.g. poetry).

@meghfossa meghfossa marked this pull request as ready for review July 25, 2022 11:30
@meghfossa meghfossa requested a review from a team as a code owner July 25, 2022 11:30
@meghfossa meghfossa requested a review from spatten July 25, 2022 11:30
Copy link
Contributor

@spatten spatten left a comment

Choose a reason for hiding this comment

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

This looks good to me, but only as someone who hasn't written a parser yet. If you want to get a more nuanced review you might want to ask someone else to take a quick look.

One general question is were you able to test this against an actual /bin/busybox binary? If you did, can you add the steps to do that in a testing plan.

src/Container/OsRelease.hs Show resolved Hide resolved
src/Container/OsRelease.hs Outdated Show resolved Hide resolved
Comment on lines +156 to +159
asum
( map (`Map.lookup` properties) ["ID"]
++ [Just "linux"] -- We should default to linux as last resort per spec!
)
Copy link
Member

Choose a reason for hiding this comment

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

Nice, TIL asum

src/Container/OsRelease.hs Outdated Show resolved Hide resolved
Comment on lines +168 to +171
-- >> parseTest propertiesParser "A=B\nC=D" = fromList [(A, B), (C, D)]
-- >> parseTest propertiesParser "A=B\n\nC=D" = fromList [(A, B), (C, D)]
propertiesParser :: Parser (Map.Map Text Text)
propertiesParser = Map.fromList <$> many (lexeme propertyParser)
Copy link
Member

Choose a reason for hiding this comment

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

I like these inline comments showing what these functions concretely do!

src/Container/OsRelease.hs Show resolved Hide resolved
@meghfossa meghfossa force-pushed the feat/container-scanning/adds-os-release branch from 8b1b97f to 4971539 Compare July 27, 2022 22:04
@meghfossa meghfossa enabled auto-merge (squash) July 27, 2022 22:07
@meghfossa meghfossa merged commit 8242ae0 into master Jul 27, 2022
@meghfossa meghfossa deleted the feat/container-scanning/adds-os-release branch July 27, 2022 22:35
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants