-
Notifications
You must be signed in to change notification settings - Fork 1
fix(security): document + opt-in redaction for source-text identity fields (#1920) #2089
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,6 +37,12 @@ pub(crate) fn push_finding<F>( | |
| // Cap source-derived string fields so a megabyte-long identifier cannot | ||
| // inflate report/receipt artifacts unboundedly (#1919). | ||
| identity.truncate_in_place(); | ||
| // Opt-in: redact source-text-bearing identity fields for CI artifacts | ||
| // where they are an info-leak surface. Structural hashes are preserved. | ||
| // (#1920) | ||
| if std::env::var("CARGO_ALLOW_REDACT_IDENTITY").as_deref() == Ok("1") { | ||
| identity.redact_source_text_fields(); | ||
|
Comment on lines
+43
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎. |
||
| } | ||
|
Comment on lines
+40
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '\n== repo files of interest ==\n'
git ls-files | rg '(^|/)(rust-toolchain(\.toml)?|Cargo\.toml|Cargo\.lock|finding_builder\.rs)$'
printf '\n== rust toolchain / msrv hints ==\n'
for f in rust-toolchain.toml rust-toolchain Cargo.toml crates/allow-rust/Cargo.toml; do
if [ -f "$f" ]; then
echo "--- $f"
cat -n "$f" | sed -n '1,220p'
fi
done
printf '\n== finding_builder.rs ==\n'
cat -n crates/allow-rust/src/finding_builder.rs | sed -n '1,220p'Repository: EffortlessMetrics/cargo-allow Length of output: 5735 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '\n== push_finding usages ==\n'
rg -n "push_finding\(" crates/allow-rust -g '!target' -g '!**/node_modules/**'
printf '\n== structural identity / redact flag related symbols ==\n'
rg -n "CARGO_ALLOW_REDACT_IDENTITY|redact_source_text_fields|OnceLock|push_finding" crates/allow-rust -g '!target' -g '!**/node_modules/**'
printf '\n== relevant surrounding files ==\n'
for f in crates/allow-rust/src/*.rs; do
echo "--- $f"
sed -n '1,220p' "$f" | rg -n "push_finding|CARGO_ALLOW_REDACT_IDENTITY|redact_source_text_fields|OnceLock|StructuralIdentity|FindingSite|FindingKind"
doneRepository: EffortlessMetrics/cargo-allow Length of output: 3188 🏁 Script executed: #!/bin/bash
set -euo pipefail
python3 - <<'PY'
import os, re, pathlib, json
root = pathlib.Path('.')
candidates = [
'rust-toolchain.toml',
'rust-toolchain',
'Cargo.toml',
'crates/allow-rust/Cargo.toml',
]
for p in candidates:
path = root / p
if path.exists():
print(f'--- {p}')
text = path.read_text(errors='replace').splitlines()
for i, line in enumerate(text[:220], 1):
if re.search(r'(toolchain|rust-version|edition|msrv|minimum supported rust)', line, re.I):
print(f'{i}:{line}')
# print top relevant context for rust-toolchain/Cargo
if p.endswith('rust-toolchain.toml') or p == 'rust-toolchain' or p.endswith('Cargo.toml'):
for i, line in enumerate(text[:80], 1):
print(f'{i}:{line}')
if i >= 80:
break
PY
printf '\n== finding_builder relevant lines ==\n'
sed -n '1,120p' crates/allow-rust/src/finding_builder.rs | nl -ba | sed -n '1,120p'
printf '\n== callers/usages ==\n'
rg -n "push_finding\(" crates/allow-rust -g '!target' -g '!**/node_modules/**'
printf '\n== env/redact symbols ==\n'
rg -n "CARGO_ALLOW_REDACT_IDENTITY|redact_source_text_fields|OnceLock" crates/allow-rust -g '!target' -g '!**/node_modules/**'Repository: EffortlessMetrics/cargo-allow Length of output: 2509 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== toolchain manifests =="
for f in rust-toolchain.toml rust-toolchain Cargo.toml crates/allow-rust/Cargo.toml; do
if [ -f "$f" ]; then
echo "--- $f"
nl -ba "$f" | sed -n '1,160p'
fi
done
echo
echo "== finding_builder.rs excerpt =="
nl -ba crates/allow-rust/src/finding_builder.rs | sed -n '1,140p'
echo
echo "== push_finding call sites =="
rg -n "push_finding\(" crates/allow-rust
echo
echo "== OnceLock usage =="
rg -n "OnceLock|CARGO_ALLOW_REDACT_IDENTITY|redact_source_text_fields" crates/allow-rustRepository: EffortlessMetrics/cargo-allow Length of output: 248 🌐 Web query:
💡 Result: The Rust standard library structure std::sync::OnceLock was stabilized in version 1.70.0 [1][2][3]. It is a thread-safe synchronization primitive that can be written to only once, functioning as a thread-safe alternative to OnceCell [1][4]. The stabilization was implemented through pull request Citations:
Cache the redaction flag once. 🤖 Prompt for AI Agents |
||
| findings.push(Finding { | ||
| kind, | ||
| family: Some(family.to_string()), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
Repository: EffortlessMetrics/cargo-allow
Length of output: 167
🏁 Script executed:
Repository: EffortlessMetrics/cargo-allow
Length of output: 50386
🏁 Script executed:
Repository: EffortlessMetrics/cargo-allow
Length of output: 50387
Redaction should preserve matching entropy
redact_source_text_fields()clears fields that still feedstable_key()/finding_identity_key()(module,container,symbol,callee,macro_name,lint).line_hint/column_hintare review hints only, not part of the key. If redacted findings participate in matching, distinct findings on the same path can collapse onto the same key; replace the cleared text with a stable digest or keep redaction out of matching inputs.🤖 Prompt for AI Agents