Skip to content

Commit

Permalink
incorporate feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
mschneider committed Dec 9, 2022
1 parent 1101a08 commit 754725e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ following to the macro to exclude it from `no-entrypoint` builds.
#[cfg(not(feature = "no-entrypoint"))]
```

#### Use as an indicator for the deployed code version

In order to simplify access to the source code we recommend to include the commit hash as `source_revision` or the release tag as `source_release`.
You can use the `option_env!` macro to automatically configure values passed to the `security_txt!` macro from the build process envioronment.

### Example

```rust
Expand All @@ -74,6 +79,8 @@ security_txt! {
// Optional Fields
preferred_languages: "en,de",
source_code: "https://github.com/example/example",
source_revision: option_env!("GITHUB_SHA").unwrap().into(),
source_release: option_env!("GITHUB_REF_NAME").unwrap().into(),
encryption: "
-----BEGIN PGP PUBLIC KEY BLOCK-----
Comment: Alice's OpenPGP certificate
Expand Down
8 changes: 2 additions & 6 deletions security-txt/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,8 @@ pub fn parse(mut data: &[u8]) -> Result<SecurityTxt, SecurityTxtError> {
.remove("project_url")
.ok_or_else(|| SecurityTxtError::MissingField("project_url".to_string()))?;
let source_code = attributes.remove("source_code");
let source_release = attributes
.remove("source_release")
.or(option_env!("GITHUB_REF_NAME").map(|s| s.into()));
let source_revision = attributes
.remove("source_revision")
.or(option_env!("GITHUB_SHA").map(|s| s.into()));
let source_release = attributes.remove("source_release");
let source_revision = attributes.remove("source_revision");
let expiry = attributes.remove("expiry");
let preferred_languages = attributes
.remove("preferred_languages")
Expand Down

0 comments on commit 754725e

Please sign in to comment.