-
Notifications
You must be signed in to change notification settings - Fork 291
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2016 from rust-lang/remo/ynxwqrvksvok
Add a `.well-known/security.txt`
- Loading branch information
Showing
5 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Contact: https://www.rust-lang.org/policies/security | ||
Expires: 2025-05-15T00:00:00.000Z |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use time::{format_description::well_known::Rfc3339, OffsetDateTime}; | ||
|
||
static TEXT: &str = include_str!("../static/text/well_known_security.txt"); | ||
|
||
#[test] | ||
fn well_known_security_is_not_about_to_expire() { | ||
let expires = TEXT.split("Expires:").nth(1).unwrap().trim(); | ||
let expires = OffsetDateTime::parse(expires, &Rfc3339).unwrap(); | ||
let one_month_from_now = OffsetDateTime::now_utc() + time::Duration::days(30); | ||
assert!( | ||
one_month_from_now < expires, | ||
" | ||
┌────────────────────────────────────────────────────────────────┐ | ||
│ │ | ||
│ I looks like the expiration date of the security policy needs │ | ||
│ updating. Before blindly updating it, please make sure the │ | ||
│ pointed-to URL still refers to the source of truth of the │ | ||
│ security policy of the Rust project. If all is well, you can │ | ||
│ update the expiration date in the relevant file: │ | ||
│ │ | ||
│ static/text/well_known_security.txt │ | ||
│ │ | ||
└────────────────────────────────────────────────────────────────┘ | ||
" | ||
); | ||
} | ||
|
||
#[test] | ||
fn well_known_security_expires_within_a_year() { | ||
let expires = TEXT.split("Expires:").nth(1).unwrap().trim(); | ||
let expires = OffsetDateTime::parse(expires, &Rfc3339).unwrap(); | ||
let one_year_from_now = OffsetDateTime::now_utc() + time::Duration::days(370); | ||
assert!( | ||
expires < one_year_from_now, | ||
"The security policy should be checked once a year, please reduce the expiration date." | ||
); | ||
} |