aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/advisory
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe/src/advisory')
-rw-r--r--crates/shirabe/src/advisory/auditor.rs20
-rw-r--r--crates/shirabe/src/advisory/partial_security_advisory.rs5
2 files changed, 13 insertions, 12 deletions
diff --git a/crates/shirabe/src/advisory/auditor.rs b/crates/shirabe/src/advisory/auditor.rs
index be78f4b..662a940 100644
--- a/crates/shirabe/src/advisory/auditor.rs
+++ b/crates/shirabe/src/advisory/auditor.rs
@@ -10,7 +10,6 @@ use crate::package::PackageInterfaceHandle;
use crate::package::base_package;
use crate::repository::RepositorySet;
use crate::util::PackageInfo;
-use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::Preg;
use shirabe_external_packages::symfony::console::formatter::OutputFormatter;
@@ -37,7 +36,10 @@ struct AuditJsonReport<'a> {
/// PHP `json_encode` emits an empty associative array as `[]`, not `{}`. Mirror that so an empty
/// map serializes as an empty JSON array.
-fn serialize_php_array<S, V>(map: &IndexMap<String, V>, serializer: S) -> Result<S::Ok, S::Error>
+fn serialize_php_array<S, V>(
+ map: &IndexMap<String, V>,
+ serializer: S,
+) -> anyhow::Result<S::Ok, S::Error>
where
S: serde::Serializer,
V: serde::Serialize,
@@ -54,7 +56,7 @@ where
fn serialize_advisories_field<S>(
map: &&IndexMap<String, Vec<AnySecurityAdvisory>>,
serializer: S,
-) -> Result<S::Ok, S::Error>
+) -> anyhow::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
@@ -64,7 +66,7 @@ where
fn serialize_abandoned_field<S>(
map: &IndexMap<String, Option<String>>,
serializer: S,
-) -> Result<S::Ok, S::Error>
+) -> anyhow::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
@@ -120,7 +122,7 @@ impl Auditor {
ignored_severities: IndexMap<String, Option<String>>,
ignore_unreachable: bool,
ignore_abandoned: IndexMap<String, Option<String>>,
- ) -> Result<i64> {
+ ) -> anyhow::Result<i64> {
let result = repo_set.get_matching_security_advisories(
packages.clone(),
format == Self::FORMAT_SUMMARY,
@@ -426,7 +428,7 @@ impl Auditor {
io: &mut dyn IOInterface,
advisories: &IndexMap<String, Vec<AnySecurityAdvisory>>,
format: &str,
- ) -> Result<()> {
+ ) -> anyhow::Result<()> {
match format {
Self::FORMAT_TABLE => {
let io_as_console = io.as_any().downcast_ref::<ConsoleIO>();
@@ -463,7 +465,7 @@ impl Auditor {
&self,
io: &ConsoleIO,
advisories: &IndexMap<String, Vec<AnySecurityAdvisory>>,
- ) -> Result<()> {
+ ) -> anyhow::Result<()> {
for package_advisories in advisories.values() {
for advisory in package_advisories {
let mut headers: Vec<String> = vec![
@@ -524,7 +526,7 @@ impl Auditor {
&self,
io: &mut dyn IOInterface,
advisories: &IndexMap<String, Vec<AnySecurityAdvisory>>,
- ) -> Result<()> {
+ ) -> anyhow::Result<()> {
let mut error: Vec<String> = vec![];
let mut first_advisory = true;
for package_advisories in advisories.values() {
@@ -572,7 +574,7 @@ impl Auditor {
io: &mut dyn IOInterface,
packages: &[CompletePackageInterfaceHandle],
format: &str,
- ) -> Result<()> {
+ ) -> anyhow::Result<()> {
io.write_error(&format!(
"<error>Found {} abandoned package{}:</error>",
packages.len() as i64,
diff --git a/crates/shirabe/src/advisory/partial_security_advisory.rs b/crates/shirabe/src/advisory/partial_security_advisory.rs
index 11b95bd..148bef4 100644
--- a/crates/shirabe/src/advisory/partial_security_advisory.rs
+++ b/crates/shirabe/src/advisory/partial_security_advisory.rs
@@ -3,7 +3,6 @@
use crate::advisory::AnySecurityAdvisory;
use crate::advisory::SecurityAdvisory;
use crate::package::version::VersionParser;
-use anyhow::Result;
use chrono::{DateTime, Utc};
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::Preg;
@@ -14,7 +13,7 @@ use shirabe_semver::constraint::SimpleConstraint;
fn serialize_constraint<S: serde::Serializer>(
c: &AnyConstraint,
serializer: S,
-) -> Result<S::Ok, S::Error> {
+) -> anyhow::Result<S::Ok, S::Error> {
serializer.serialize_str(&c.get_pretty_string())
}
@@ -32,7 +31,7 @@ impl PartialSecurityAdvisory {
package_name: &str,
data: &IndexMap<String, PhpMixed>,
parser: &VersionParser,
- ) -> Result<AnySecurityAdvisory> {
+ ) -> anyhow::Result<AnySecurityAdvisory> {
let affected_versions_str = data["affectedVersions"].as_string().unwrap_or("");
let constraint: AnyConstraint = match parser.parse_constraints(affected_versions_str) {