Expand description
§use-security
Feature-gated facade crate for RustUse security primitives.
§Experimental
use-security is experimental while the use-security workspace remains below 0.3.0. Expect small API adjustments during the first release wave.
§Example
[dependencies]
use-security = { version = "0.0.1", default-features = false, features = ["cve", "cwe", "cvss"] }ⓘ
use use_security::{CveId, CweId, CvssScore, severity_from_score};
let cve: CveId = "CVE-2024-12345".parse()?;
let cwe: CweId = "CWE-79".parse()?;
let score = CvssScore::new(9.8)?;
assert_eq!(cve.as_str(), "CVE-2024-12345");
assert_eq!(cwe.to_string(), "CWE-79");
assert_eq!(severity_from_score(score).as_str(), "critical");§Feature Flags
cve: re-exportuse-cvecwe: re-exportuse-cwecvss: re-exportuse-cvssowasp: re-exportuse-owasprisk: re-exportuse-security-riskthreat: re-exportuse-threatfinding: re-exportuse-security-findingauthn: re-exportuse-authnauthz: re-exportuse-authzsecret: re-exportuse-secretcrypto: re-exportuse-cryptosecurity-header: re-exportuse-security-headersbom: re-exportuse-sbomfull: enable all child crates
§Scope
- Facade imports and namespace aliases for focused
use-securitychild crates. - Small primitive metadata APIs for security-related identifiers, labels, and validation helpers.
§Non-goals
- Implementation logic beyond re-exports.
- Security scanning, authentication, authorization, encryption, SBOM generation, or policy enforcement.
§License
Licensed under either of the following, at your option:
- Apache License, Version 2.0
- MIT license
Re-exports§
pub use use_authn as authn;pub use use_authz as authz;pub use use_crypto as crypto;pub use use_cve as cve;pub use use_cvss as cvss;pub use use_cwe as cwe;pub use use_owasp as owasp;pub use use_security_risk as risk;pub use use_threat as threat;pub use use_security_finding as finding;pub use use_secret as secret;pub use use_security_header as security_header;pub use use_sbom as sbom;
Structs§
- Access
Action - Access
Resource - Access
Subject - Claim
Name - CveId
- A validated CVE identifier such as
CVE-2024-12345. - CveReference
- A lightweight CVE reference URL or label.
- CveSequence
- A CVE sequence component with at least four digits.
- CveSource
- A lightweight source label for CVE metadata.
- CveYear
- A four-digit CVE year.
- Cvss
Metric Name - Cvss
Metric Value - Cvss
Score - A validated CVSS base score.
- Cvss
Vector - CweId
- A validated CWE identifier such as
CWE-79. - CweNumber
- Numeric CWE identifier component.
- Finding
Evidence - Finding
Location - Finding
Reference - Finding
Source - Masked
Secret - A wrapper that never exposes its value through
DebugorDisplay. - Owasp
Risk Id - Lightweight OWASP risk identifier.
- Permission
Name - Risk
Owner - Role
Name - Sbom
Component - SBOM component metadata.
- Sbom
Component Name - Sbom
Component Version - Sbom
Digest - Sbom
License Expression - Sbom
Package Url - A package URL metadata value.
- Scope
Name - Secret
Name - Secret
Reference - Security
Finding - Security finding metadata.
- Security
Finding Id - Security
Header Name - A validated HTTP security header name.
- Security
Risk - Security risk metadata.
- Security
Risk Id - Threat
Id - Threat
Scenario - A compact threat scenario metadata record.
- Threat
Surface
Enums§
- Access
Decision - Access decision labels.
- Authentication
Factor - Authentication factor labels.
- Authentication
Method - Authentication method labels.
- Authentication
Scheme - HTTP or application authentication scheme labels.
- Authn
Parse Error - Error returned when an authentication label cannot be parsed.
- Authorization
Model - Authorization model labels.
- Authz
Name Error - Error returned when authorization names are invalid.
- Authz
Parse Error - Error returned when an authorization label cannot be parsed.
- Content
Security Policy Directive - Content Security Policy directive labels.
- Cors
Policy Kind - CORS policy labels.
- Credential
Kind - Credential kind labels.
- Crypto
Algorithm - Broad cryptographic algorithm category labels.
- Crypto
Encoding - Cryptographic encoding labels.
- Crypto
Parse Error - Error returned when a crypto label cannot be parsed.
- Crypto
Strength - Cryptographic strength labels.
- CveId
Error - Error returned when a CVE identifier is invalid.
- CveRecord
Kind - CVE record kind metadata.
- CveStatus
- CVE publication status metadata.
- CveText
Error - Error returned when CVE text metadata is empty.
- Cvss
Attack Complexity - CVSS attack-complexity labels.
- Cvss
Attack Vector - CVSS attack-vector labels.
- Cvss
Impact Level - CVSS impact-level labels.
- Cvss
Parse Error - Error returned when a CVSS label cannot be parsed.
- Cvss
Privileges Required - CVSS privileges-required labels.
- Cvss
Scope - CVSS scope labels.
- Cvss
Score Error - Error returned when a CVSS score is invalid.
- Cvss
Severity - CVSS severity labels.
- Cvss
Text Error - Error returned when CVSS text metadata is invalid.
- Cvss
User Interaction - CVSS user-interaction labels.
- Cvss
Version - CVSS version labels.
- CweId
Error - Error returned when a CWE identifier is invalid.
- CweImpact
Kind - CWE impact category labels.
- CweLikelihood
- CWE likelihood labels.
- CweParse
Error - Error returned when a CWE label cannot be parsed.
- CweTaxonomy
Source - CWE taxonomy source labels.
- CweWeakness
Kind - CWE weakness category labels.
- Encryption
Algorithm - Encryption algorithm labels.
- Finding
Confidence - Finding confidence labels.
- Finding
Kind - Finding source category labels.
- Finding
Reference Kind - Lightweight finding reference categories.
- Finding
Severity - Finding severity labels.
- Finding
Status - Finding lifecycle status labels.
- Frame
Options Kind - X-Frame-Options labels.
- Hash
Algorithm - Hash algorithm labels.
- KeyAlgorithm
- Key algorithm labels.
- KeyKind
- Key kind labels.
- KeyUsage
- Key usage labels.
- MfaStatus
- MFA status labels.
- Owasp
Control Area - Application security control-area labels.
- Owasp
Parse Error - Error returned when an OWASP label cannot be parsed.
- Owasp
Project Kind - OWASP project labels.
- Owasp
Text Error - Error returned when OWASP text metadata is invalid.
- Owasp
Top10 Category - OWASP Top 10 style category labels.
- Owasp
Top10 Version - OWASP Top 10 version labels.
- Password
Policy Level - Password policy strength labels.
- Permissions
Policy Directive - Permissions policy directive labels.
- Policy
Effect - Policy effect labels.
- Referrer
Policy Kind - Referrer policy labels.
- Remediation
Status - Remediation status labels.
- Risk
Category - Risk category labels.
- Risk
Impact - Risk impact labels.
- Risk
Likelihood - Risk likelihood labels.
- Risk
Priority - Sortable risk priority labels.
- Risk
Severity - Risk severity labels.
- Risk
Status - Risk status labels.
- Risk
Treatment - Risk treatment labels.
- Sbom
Format - SBOM format labels.
- Sbom
Parse Error - Error returned when an SBOM label cannot be parsed.
- Sbom
Relationship Kind - SBOM relationship labels.
- Sbom
Text Error - Error returned when SBOM text metadata is invalid.
- Secret
Kind - Secret kind labels.
- Secret
Parse Error - Error returned when a secret label cannot be parsed.
- Secret
Provider - Secret provider labels.
- Secret
Redaction - Secret redaction strategy labels.
- Secret
Rotation Status - Secret rotation status labels.
- Secret
Scope - Secret scope labels.
- Secret
Sensitivity - Secret sensitivity labels.
- Secret
Text Error - Error returned when secret text metadata is invalid.
- Security
Finding Error - Error returned when finding metadata is invalid.
- Security
Header Kind - Security header categories.
- Security
Header Name Error - Error returned when a security header name is invalid.
- Security
Header Parse Error - Error returned when a security header label cannot be parsed.
- Security
Risk Error - Error returned when security risk metadata is invalid.
- Session
Kind - Session kind labels.
- Signature
Algorithm - Signature algorithm labels.
- Supply
Chain Risk Kind - Supply-chain risk labels.
- Threat
Actor Kind - Threat actor labels.
- Threat
Capability - Threat capability labels.
- Threat
Category - Threat category labels.
- Threat
Error - Error returned when threat metadata is invalid.
- Threat
Intent - Threat intent labels.
- Threat
Model Kind - Threat model kind labels.
- Token
Binding Kind - Token binding kind labels.
- Transport
Security Directive - Strict-Transport-Security directive labels.
Constants§
- CWE_
22_ PATH_ TRAVERSAL - CWE_
78_ OS_ COMMAND_ INJECTION - CWE_
79_ XSS - CWE_
89_ SQL_ INJECTION - CWE_
94_ CODE_ INJECTION - CWE_
200_ SENSITIVE_ INFORMATION_ EXPOSURE - CWE_
287_ IMPROPER_ AUTHENTICATION - CWE_
352_ CSRF - CWE_
862_ MISSING_ AUTHORIZATION - CWE_
918_ SSRF
Functions§
- is_
deprecated_ like - Returns
truewhen a hash algorithm label is deprecated-like. - mask_
all - Masks every character in a value.
- mask_
keep_ last - Masks all but the last
countcharacters in a value. - mask_
keep_ prefix_ suffix - Masks the middle while keeping a prefix and suffix.
- priority_
from_ likelihood_ impact - Returns a sortable priority from likelihood and impact.
- severity_
from_ score - Returns the CVSS severity bucket for a validated score.