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

feature audit #42

Merged
merged 25 commits into from
Oct 7, 2023
Merged

feature audit #42

merged 25 commits into from
Oct 7, 2023

Conversation

uncomfyhalomacro
Copy link
Collaborator

closes #38

Signed-off-by: Soc Virnyl Estela <[email protected]>
clap's command + flatten is the best 😭

Signed-off-by: Soc Virnyl Estela <[email protected]>
@uncomfyhalomacro uncomfyhalomacro added enhancement New feature or request good first issue Good for newcomers labels Sep 19, 2023
@uncomfyhalomacro uncomfyhalomacro self-assigned this Sep 19, 2023
the lints is propagated from lib.rs anyway

Signed-off-by: Soc Virnyl Estela <[email protected]>
Signed-off-by: Soc Virnyl Estela <[email protected]>
cargo/src/bin/cargo_vendor.rs Outdated Show resolved Hide resolved
Signed-off-by: Soc Virnyl Estela <[email protected]>
Signed-off-by: Soc Virnyl Estela <[email protected]>
Signed-off-by: Soc Virnyl Estela <[email protected]>
@Firstyear
Copy link
Collaborator

I like the use of the serde xml defs for reading the service file :P

Signed-off-by: Soc Virnyl Estela <[email protected]>
How it works:
This binary will try to run `cargo audit --file <pathtolockfile>`.

This binary will read `_service` file and searches for the service
that corresponds to `cargo_vendor` and attempts to audit them.
If `cargo_vendor` service exists, it will use the following params,
if they exist:
1. `cargotoml`
2. `src`, `srctar`, `srcdir`

`cargotoml`:
The `cargotoml` path is used to check if there is also a lockfile to audit
in the path where it resides. Otherwise, it will attempt to regenerate
the lockfile.

`src` `srctar` `srcdir`:
This will be used to check the lockfile of the sources and audit it.

`lockfiles`:
In case additional lockfiles exist to audit from sources.

Vendored tarball:
Since `cargo_vendor` generates a lockfile and also includes it
when generating the vendored tarball, we also check the lockfiles
in those contents as well.

Signed-off-by: Soc Virnyl Estela <[email protected]>
Signed-off-by: Soc Virnyl Estela <[email protected]>
and banana sauce as well

Signed-off-by: Soc Virnyl Estela <[email protected]>
Signed-off-by: Soc Virnyl Estela <[email protected]>
since auditopts does not have `Src`, we can just use
our generated `Opts` from `Services` to get the `Src`s

we then implement the `Audit` trait on `Src` so we can just

```
let s: Src = ohsomesrc;
s.run_audit()?;
```

`run_audit` runs all the other audit methods

Signed-off-by: Soc Virnyl Estela <[email protected]>
fn process_lockfiles(self) -> io::Result<()>;
// Run audit sets the workdir before running other stuff
fn run_audit(self, opts: &Opts) -> Result<(), AuditFailed>;
fn audit_vendored_tar(self, opts: &Opts, workdir: &Path) -> io::Result<()>;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You don't need to have opts for this future self, just extract and get the Cargo.lock. You also need to check if there are multiple vendored tarballs. So in this case, use the glob crate and use /**vendor**.tar.**/ and check their lockfiles.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ahhh true. That's a good point.

cleanup/improvements to-be-done in the future commits

Signed-off-by: Soc Virnyl Estela <[email protected]>
@uncomfyhalomacro uncomfyhalomacro marked this pull request as ready for review October 6, 2023 13:46
Copy link
Collaborator Author

@uncomfyhalomacro uncomfyhalomacro left a comment

Choose a reason for hiding this comment

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

Bet

@uncomfyhalomacro uncomfyhalomacro merged commit 35f7016 into master Oct 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TODO: migration of OBS Service cargo audit
2 participants