Skip to content

Commit f3cb67f

Browse files
Update Rust crate tough to 0.20.0 [SECURITY] (#7889)
1 parent bc30ba8 commit f3cb67f

File tree

12 files changed

+53
-51
lines changed

12 files changed

+53
-51
lines changed

Cargo.lock

Lines changed: 19 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ tokio-tungstenite = "0.23.1"
678678
tokio-util = { version = "0.7.13", features = ["io", "io-util"] }
679679
toml = "0.8.20"
680680
toml_edit = "0.22.24"
681-
tough = { version = "0.19.0", features = [ "http" ] }
681+
tough = { version = "0.20.0", features = [ "http" ] }
682682
transceiver-controller = { git = "https://github.com/oxidecomputer/transceiver-control", features = [ "api-traits" ] }
683683
trybuild = "1.0.103"
684684
tufaceous = { git = "https://github.com/oxidecomputer/tufaceous", branch = "main" }

clients/bootstrap-agent-client/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,3 @@ uuid.workspace = true
2121
omicron-uuid-kinds.workspace = true
2222
omicron-workspace-hack.workspace = true
2323
oxnet.workspace = true
24-
semver.workspace = true

clients/bootstrap-agent-client/src/lib.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ progenitor::generate_api!(
2727
TypedUuidForRackInitKind = omicron_uuid_kinds::RackInitUuid,
2828
TypedUuidForRackResetKind = omicron_uuid_kinds::RackResetUuid,
2929
},
30-
convert = {
31-
{
32-
type = "string",
33-
pattern = r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$",
34-
} = semver::Version,
35-
}
3630
);
3731

3832
impl omicron_common::api::external::ClientError for types::Error {

openapi/bootstrap-agent.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,11 @@
203203
}
204204
]
205205
},
206+
"ArtifactVersion": {
207+
"description": "An artifact version.\n\nThis is a freeform identifier with some basic validation. It may be the serialized form of a semver version, or a custom identifier that uses the same character set as a semver, plus `_`.\n\nThe exact pattern accepted is `^[a-zA-Z0-9._+-]{1,63}$`.\n\n# Ord implementation\n\n`ArtifactVersion`s are not intended to be sorted, just compared for equality. `ArtifactVersion` implements `Ord` only for storage within sorted collections.",
208+
"type": "string",
209+
"pattern": "^[a-zA-Z0-9._+-]{1,63}$"
210+
},
206211
"Baseboard": {
207212
"description": "Describes properties that should uniquely identify a Gimlet.",
208213
"oneOf": [
@@ -559,8 +564,7 @@
559564
"type": "string"
560565
},
561566
"version": {
562-
"type": "string",
563-
"pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"
567+
"$ref": "#/components/schemas/ArtifactVersion"
564568
}
565569
},
566570
"required": [

sled-agent/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ repo-depot-api.workspace = true
7474
repo-depot-client.workspace = true
7575
reqwest = { workspace = true, features = ["rustls-tls", "stream"] }
7676
schemars = { workspace = true, features = ["chrono", "uuid1"] }
77-
semver.workspace = true
7877
serde.workspace = true
7978
serde_human_bytes.workspace = true
8079
serde_json = { workspace = true, features = ["raw_value"] }
@@ -101,6 +100,8 @@ tokio = { workspace = true, features = ["full"] }
101100
tokio-stream.workspace = true
102101
tokio-util.workspace = true
103102
toml.workspace = true
103+
tufaceous-artifact.workspace = true
104+
tufaceous-brand-metadata.workspace = true
104105
usdt.workspace = true
105106
uuid.workspace = true
106107
zeroize.workspace = true
@@ -110,7 +111,6 @@ omicron-workspace-hack.workspace = true
110111
slog-error-chain.workspace = true
111112
walkdir.workspace = true
112113
zip.workspace = true
113-
tufaceous-brand-metadata.workspace = true
114114

115115
[target.'cfg(target_os = "illumos")'.dependencies]
116116
opte-ioctl.workspace = true
@@ -127,7 +127,6 @@ omicron-test-utils.workspace = true
127127
pretty_assertions.workspace = true
128128
rcgen.workspace = true
129129
reqwest = { workspace = true, features = ["blocking"] }
130-
semver.workspace = true
131130
subprocess.workspace = true
132131
slog-async.workspace = true
133132
slog-term.workspace = true

sled-agent/bootstrap-agent-api/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ omicron-common.workspace = true
1313
omicron-uuid-kinds.workspace = true
1414
omicron-workspace-hack.workspace = true
1515
schemars.workspace = true
16-
semver.workspace = true
1716
serde.workspace = true
1817
sled-agent-types.workspace = true
1918
sled-hardware-types.workspace = true
19+
tufaceous-artifact.workspace = true

sled-agent/bootstrap-agent-api/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ use dropshot::{
1313
};
1414
use omicron_uuid_kinds::{RackInitUuid, RackResetUuid};
1515
use schemars::JsonSchema;
16-
use semver::Version;
1716
use serde::{Deserialize, Serialize};
1817
use sled_agent_types::{
1918
rack_init::RackInitializeRequest, rack_ops::RackOperationStatus,
2019
};
2120
use sled_hardware_types::Baseboard;
21+
use tufaceous_artifact::ArtifactVersion;
2222

2323
#[dropshot::api_description]
2424
pub trait BootstrapAgentApi {
@@ -86,5 +86,5 @@ pub trait BootstrapAgentApi {
8686
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema, PartialEq)]
8787
pub struct Component {
8888
pub name: String,
89-
pub version: Version,
89+
pub version: ArtifactVersion,
9090
}

sled-agent/src/updates.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use bootstrap_agent_api::Component;
88
use camino::{Utf8Path, Utf8PathBuf};
99
use serde::{Deserialize, Serialize};
10+
use tufaceous_artifact::ArtifactVersionError;
1011
use tufaceous_brand_metadata::Metadata;
1112

1213
#[derive(thiserror::Error, Debug)]
@@ -25,8 +26,12 @@ pub enum Error {
2526
err: std::io::Error,
2627
},
2728

28-
#[error("Cannot parse semver in {path}")]
29-
Semver { path: Utf8PathBuf, err: semver::Error },
29+
#[error("Cannot parse artifact version in {path}")]
30+
ArtifactVersion {
31+
path: Utf8PathBuf,
32+
#[source]
33+
err: ArtifactVersionError,
34+
},
3035
}
3136

3237
fn default_zone_artifact_path() -> Utf8PathBuf {
@@ -99,12 +104,13 @@ impl UpdateManager {
99104
.await
100105
.map_err(|err| io_err(&version_path, err))?;
101106

102-
// Extract the name and semver version
107+
// Extract the name and artifact version
103108
let name = "sled-agent".to_string();
104-
let version = version.parse().map_err(|err| Error::Semver {
105-
path: version_path.to_path_buf(),
106-
err,
107-
})?;
109+
let version =
110+
version.parse().map_err(|err| Error::ArtifactVersion {
111+
path: version_path.to_path_buf(),
112+
err,
113+
})?;
108114

109115
components.push(crate::updates::Component { name, version });
110116
}
@@ -119,9 +125,9 @@ mod test {
119125
use super::*;
120126
use camino_tempfile::NamedUtf8TempFile;
121127
use flate2::write::GzEncoder;
122-
use semver::Version;
123128
use std::io::Write;
124129
use tar::Builder;
130+
use tufaceous_artifact::ArtifactVersion;
125131

126132
#[tokio::test]
127133
async fn test_query_no_components() {
@@ -172,7 +178,7 @@ mod test {
172178
um.components_get().await.expect("Failed to get components");
173179
assert_eq!(components.len(), 1);
174180
assert_eq!(components[0].name, "test-pkg".to_string());
175-
assert_eq!(components[0].version, Version::new(2, 0, 0));
181+
assert_eq!(components[0].version, ArtifactVersion::new_const("2.0.0"));
176182
}
177183

178184
#[tokio::test]
@@ -194,6 +200,6 @@ mod test {
194200
um.components_get().await.expect("Failed to get components");
195201
assert_eq!(components.len(), 1);
196202
assert_eq!(components[0].name, "sled-agent".to_string());
197-
assert_eq!(components[0].version, Version::new(1, 2, 3));
203+
assert_eq!(components[0].version, ArtifactVersion::new_const("1.2.3"));
198204
}
199205
}

update-common/src/artifacts/artifacts_with_plan.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ impl ArtifactsWithPlan {
214214
.repo()
215215
.targets()
216216
.signed
217-
.find_target(&target_name)
217+
.find_target(&target_name, false)
218218
.map_err(|error| RepositoryError::TargetHashRead {
219219
target: artifact.target.clone(),
220220
error: Box::new(error),

0 commit comments

Comments
 (0)