Skip to content

Commit

Permalink
fix(osv): treat published as optional
Browse files Browse the repository at this point in the history
The spec says it's optional. So let's make it optional.

Closes #990
  • Loading branch information
ctron committed Nov 11, 2024
1 parent 1fd508f commit 9c457e9
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 3 deletions.
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ postgresql_commands = { version = "0.16.3", default-features = false, features =
#cpe = { git = "https://github.com/ctron/cpe-rs", rev = "c3c05e637f6eff7dd4933c2f56d070ee2ddfb44b" }
# required due to https://github.com/voteblake/csaf-rs/pull/29
csaf = { git = "https://github.com/chirino/csaf-rs", rev = "414896904bc5e5287fd88b1daef5c27f70503d01" }
# required due to https://github.com/gcmurphy/osv/pull/51
osv = { git = "http://github.com/ctron/osv", rev = "b53f1590bbbdc663e3efe405f1fa2603e71e8680" }

# to pickup fix: https://github.com/Abraxas-365/langchain-rust/pull/246
# and fix: https://github.com/Abraxas-365/langchain-rust/pull/250
Expand Down
12 changes: 12 additions & 0 deletions etc/test-data/osv/PYSEC-2024-55.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
id: PYSEC-2024-55
modified: 0001-01-01T00:00:00Z
details: Malicious package. Exfiltrated secrets to a target server.
affected:
- package:
ecosystem: PyPI
name: cipherbcrypt
purl: pkg:pypi/cipherbcrypt
ranges:
- type: ECOSYSTEM
events:
- introduced: "0"
14 changes: 14 additions & 0 deletions modules/fundamental/tests/advisory/osv/ingest.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use test_context::test_context;
use test_log::test;
use trustify_module_ingestor::service::Format;
use trustify_test_context::TrustifyContext;

#[test_context(TrustifyContext)]
#[test(tokio::test)]
async fn pypa_yaml(ctx: &TrustifyContext) -> anyhow::Result<()> {
let result = ctx
.ingest_document_as("osv/PYSEC-2024-55.yaml", Format::OSV)
.await?;

Ok(())
}
1 change: 1 addition & 0 deletions modules/fundamental/tests/advisory/osv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#![allow(clippy::expect_used)]

mod delete;
mod ingest;
mod reingest;

use osv::schema::{Event, Vulnerability};
Expand Down
2 changes: 1 addition & 1 deletion modules/ingestor/src/service/advisory/osv/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl<'g> OsvLoader<'g> {
// TODO(#899): check if we have some kind of version information
version: None,
issuer,
published: Some(osv.published.into_time()),
published: osv.published.map(ChronoExt::into_time),
modified: Some(osv.modified.into_time()),
withdrawn: osv.withdrawn.map(ChronoExt::into_time),
};
Expand Down

0 comments on commit 9c457e9

Please sign in to comment.