Lint against RTL unicode codepoints in literals and comments
Address CVE-2021-42574.
This commit is contained in:
parent
38b01d9065
commit
c0b134582a
12 changed files with 535 additions and 10 deletions
|
@ -3518,6 +3518,34 @@ declare_lint! {
|
|||
@feature_gate = sym::non_exhaustive_omitted_patterns_lint;
|
||||
}
|
||||
|
||||
declare_lint! {
|
||||
/// The `text_direction_codepoint_in_comment` lint detects Unicode codepoints in comments that
|
||||
/// change the visual representation of text on screen in a way that does not correspond to
|
||||
/// their on memory representation.
|
||||
///
|
||||
/// ### Example
|
||||
///
|
||||
/// ```rust,compile_fail
|
||||
/// #![deny(text_direction_codepoint_in_comment)]
|
||||
/// fn main() {
|
||||
/// println!("{:?}"); // '');
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// {{produces}}
|
||||
///
|
||||
/// ### Explanation
|
||||
///
|
||||
/// Unicode allows changing the visual flow of text on screen in order to support scripts that
|
||||
/// are written right-to-left, but a specially crafted comment can make code that will be
|
||||
/// compiled appear to be part of a comment, depending on the software used to read the code.
|
||||
/// To avoid potential problems or confusion, such as in CVE-2021-42574, by default we deny
|
||||
/// their use.
|
||||
pub TEXT_DIRECTION_CODEPOINT_IN_COMMENT,
|
||||
Deny,
|
||||
"invisible directionality-changing codepoints in comment"
|
||||
}
|
||||
|
||||
declare_lint! {
|
||||
/// The `deref_into_dyn_supertrait` lint is output whenever there is a use of the
|
||||
/// `Deref` implementation with a `dyn SuperTrait` type as `Output`.
|
||||
|
|
|
@ -306,6 +306,7 @@ pub enum BuiltinLintDiagnostics {
|
|||
TrailingMacro(bool, Ident),
|
||||
BreakWithLabelAndLoop(Span),
|
||||
NamedAsmLabel(String),
|
||||
UnicodeTextFlow(Span, String),
|
||||
}
|
||||
|
||||
/// Lints that are buffered up early on in the `Session` before the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue