Skip to content

Commit

Permalink
fix: replace chrono with time for security vuln fix
Browse files Browse the repository at this point in the history
chrono depends on an old version of the time crate, which is vulnerable
to CVE-2020-26235. Replace everything with the updated time crate -- we
don't need all the functionality from the chrono crate anyway.
  • Loading branch information
ericswpark committed Jul 17, 2023
1 parent 2965321 commit 530f25c
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 191 deletions.
221 changes: 34 additions & 187 deletions release-helper/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 release-helper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license-file = "LICENSE"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
chrono = "0.4.26"
time = { version = "0.3.23", features = ["formatting", "local-offset", "macros"] }
clap = { version = "4.3.10", features = ["derive"] }
regex = "1.8.4"
semver = "1.0.17"
10 changes: 7 additions & 3 deletions release-helper/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use chrono::prelude::Local;
use clap::{Parser, Subcommand};
use std::fs;
use std::io::BufReader;
use std::process::Command;
use std::{io::BufRead, path::Path};
use time::{format_description::FormatItem, OffsetDateTime};

use semver::Version;

Expand All @@ -15,6 +15,9 @@ const VERSION: &str = env!("CARGO_PKG_VERSION");
const CHANGELOG_FILE_NAME: &str = "CHANGELOG.md";
const VERSION_FILE_NAME: &str = "version.txt";

// Define timestamp format
const TIMESTAMP_FORMAT: &[FormatItem] = time::macros::format_description!("[year]-[month]-[day]");

#[derive(Parser, Debug)]
#[command(name = "shipper-release")]
#[command(author = "Eric Park <me@ericswpark.com>")]
Expand Down Expand Up @@ -96,9 +99,10 @@ fn check_running_directory() -> bool {
}

fn today_iso8601() -> String {
let today = Local::now();
let today =
OffsetDateTime::now_local().expect("Could not determine the UTC offset on this system!");

today.format("%Y-%m-%d").to_string()
today.format(TIMESTAMP_FORMAT).unwrap()
}

fn generate_changelog(major: bool, minor: bool, patch: bool) {
Expand Down

0 comments on commit 530f25c

Please sign in to comment.