Skip to content

Commit

Permalink
fix(wadm-types): Address RUSTSEC-2024-0370
Browse files Browse the repository at this point in the history
  • Loading branch information
joonas committed Oct 21, 2024
1 parent 9972d4d commit 271a8da
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 50 deletions.
33 changes: 4 additions & 29 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ tracing-futures = "0.2"
tracing-opentelemetry = { version = "0.17" }
tracing-subscriber = { version = "0.3.7", features = ["env-filter", "json"] }
ulid = { version = "1", features = ["serde"] }
utoipa = "4"
utoipa = "5"
uuid = "1"
wadm = { version = "0.17.1", path = "./crates/wadm" }
wadm-client = { version = "0.6.1", path = "./crates/wadm-client" }
Expand Down
2 changes: 1 addition & 1 deletion crates/wadm-types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "wadm-types"
description = "Types and validators for the wadm API"
version = "0.6.1"
version = "0.7.0"
edition = "2021"
authors = ["wasmCloud Team"]
keywords = ["webassembly", "wasmcloud", "wadm"]
Expand Down
39 changes: 20 additions & 19 deletions crates/wadm-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::collections::{BTreeMap, HashMap};

use schemars::JsonSchema;
use serde::{de, Deserialize, Serialize};
use utoipa::ToSchema;

pub mod api;
#[cfg(feature = "wit")]
Expand Down Expand Up @@ -37,7 +38,7 @@ pub const LINK_TRAIT: &str = "link";
pub const LATEST_VERSION: &str = "latest";

/// Manifest file based on the Open Application Model (OAM) specification for declaratively managing wasmCloud applications
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, utoipa::ToSchema, JsonSchema)]
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, ToSchema, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct Manifest {
/// The OAM version of the manifest
Expand Down Expand Up @@ -171,7 +172,7 @@ impl Manifest {
}

/// The metadata describing the manifest
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema)]
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, ToSchema, JsonSchema)]
pub struct Metadata {
/// The name of the manifest. This must be unique per lattice
pub name: String,
Expand All @@ -184,7 +185,7 @@ pub struct Metadata {
}

/// A representation of an OAM specification
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema)]
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, ToSchema, JsonSchema)]
pub struct Specification {
/// The list of components for describing an application
pub components: Vec<Component>,
Expand All @@ -197,7 +198,7 @@ pub struct Specification {
}

/// A policy definition
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema)]
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, ToSchema, JsonSchema)]
pub struct Policy {
/// The name of this policy
pub name: String,
Expand All @@ -209,7 +210,7 @@ pub struct Policy {
}

/// A component definition
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema)]
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, ToSchema, JsonSchema)]
// TODO: figure out why this can't be uncommented
// #[serde(deny_unknown_fields)]
pub struct Component {
Expand Down Expand Up @@ -258,7 +259,7 @@ impl Component {
}

/// Properties that can be defined for a component
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema)]
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, ToSchema, JsonSchema)]
#[serde(tag = "type")]
pub enum Properties {
#[serde(rename = "component", alias = "actor")]
Expand All @@ -267,7 +268,7 @@ pub enum Properties {
Capability { properties: CapabilityProperties },
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema)]
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, ToSchema, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct ComponentProperties {
/// The image reference to use. Required unless the component is a shared component
Expand All @@ -292,15 +293,15 @@ pub struct ComponentProperties {
pub secrets: Vec<SecretProperty>,
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Default, JsonSchema)]
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Default, ToSchema, JsonSchema)]
pub struct ConfigDefinition {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub config: Vec<ConfigProperty>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub secrets: Vec<SecretProperty>,
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash, JsonSchema)]
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash, ToSchema, JsonSchema)]
pub struct SecretProperty {
/// The name of the secret. This is used by a reference by the component or capability to
/// get the secret value as a resource.
Expand All @@ -310,7 +311,7 @@ pub struct SecretProperty {
pub properties: SecretSourceProperty,
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash, JsonSchema)]
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash, ToSchema, JsonSchema)]
pub struct SecretSourceProperty {
/// The policy to use for retrieving the secret.
pub policy: String,
Expand All @@ -325,7 +326,7 @@ pub struct SecretSourceProperty {
pub version: Option<String>,
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema)]
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, ToSchema, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct CapabilityProperties {
/// The image reference to use. Required unless the component is a shared component
Expand All @@ -350,15 +351,15 @@ pub struct CapabilityProperties {
pub secrets: Vec<SecretProperty>,
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema)]
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, ToSchema, JsonSchema)]
pub struct SharedApplicationComponentProperties {
/// The name of the shared application
pub name: String,
/// The name of the component in the shared application
pub component: String,
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema)]
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, ToSchema, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct Trait {
/// The type of trait specified. This should be a unique string for the type of scaler. As we
Expand Down Expand Up @@ -405,7 +406,7 @@ impl Trait {
}

/// Properties for defining traits
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema)]
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, ToSchema, JsonSchema)]
#[serde(untagged)]
#[allow(clippy::large_enum_variant)]
pub enum TraitProperty {
Expand Down Expand Up @@ -449,7 +450,7 @@ impl From<SpreadScalerProperty> for TraitProperty {
///
/// Will result in two config scalers being created, one with the name `basic-kv` and one with the
/// name `default-port`. Wadm will not resolve collisions with configuration names between manifests.
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema)]
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, ToSchema, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct ConfigProperty {
/// Name of the config to ensure exists
Expand All @@ -469,7 +470,7 @@ impl PartialEq<ConfigProperty> for String {
}

/// Properties for links
#[derive(Debug, Serialize, Clone, PartialEq, Eq, JsonSchema, Default)]
#[derive(Debug, Serialize, Clone, PartialEq, Eq, ToSchema, JsonSchema, Default)]
#[serde(deny_unknown_fields)]
pub struct LinkProperty {
/// WIT namespace for the link
Expand Down Expand Up @@ -569,7 +570,7 @@ impl<'de> Deserialize<'de> for LinkProperty {
}
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Default, JsonSchema)]
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Default, ToSchema, JsonSchema)]
pub struct TargetConfig {
/// The target this link applies to. This should be the name of a component in the manifest
pub name: String,
Expand All @@ -586,7 +587,7 @@ impl PartialEq<TargetConfig> for String {
}

/// Properties for spread scalers
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema)]
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, ToSchema, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct SpreadScalerProperty {
/// Number of instances to spread across matching requirements
Expand All @@ -598,7 +599,7 @@ pub struct SpreadScalerProperty {
}

/// Configuration for various spreading requirements
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema)]
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, ToSchema, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct Spread {
/// The name of this spread requirement
Expand Down

0 comments on commit 271a8da

Please sign in to comment.