Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ semver = { version = "1.0.24", features = ["serde"] }
serde = { version = "1.0.210", features = ["derive"] }
serde_json = { version = "1.0.132", features = ["preserve_order", "unbounded_depth"] }
serde_stacker = { version = "0.1.12" }
serde-saphyr = { version = "1.1.0", default-features = false, features = ["deserialize", "serialize"] }
serde-saphyr = { version = "1.2.0", default-features = false, features = ["deserialize", "serialize"] }
shlex = { version = "2.0.0" }
globset = { version = "0.4.18" }
granit-parser = { version = "1.1.0" }
granit-parser = { version = "1.2.0" }
similar = { version = "3.0.0" }
ssl-certs = { version = "0.1.1" }
strum = { version = "0.28.0", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/prek/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ mod tests {
),
(
r#"["ci\tslow"]"#,
"group name `ci\tslow` cannot contain whitespace",
"group name `ci\\tslow` cannot contain whitespace",
),
(
r#"["@custom"]"#,
Expand Down
21 changes: 21 additions & 0 deletions crates/prek/src/hooks/pre_commit_hooks/check_yaml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ fn check_loaded(filename: &Path, content: &[u8], allow_multi_docs: bool) -> Hook
emit_comments: false,
// Do not require `!!binary` scalars to decode as UTF-8. See #1102.
ignore_binary_tag_for_string: true,
// Match ruamel.yaml's safe loader by rejecting tags without constructors. See #2604.
reject_unsupported_tags: true,
// The scalar values are discarded, so only validate whether they are
// legal YAML, not whether an untyped data model can represent them. See #2544.
reject_non_finite_typeless_float: false,
Expand Down Expand Up @@ -307,6 +309,25 @@ key2: value2
Ok(())
}

#[test]
fn test_unknown_yaml_tag_requires_unsafe() {
let filename = Path::new("tagged.yaml");
let content = b"foo: !reference [.bar, script]\n";

let result = check_loaded(filename, content, false);
assert_eq!(result.exit_status, 1);
insta::assert_snapshot!(String::from_utf8_lossy(&result.output), @r#"
tagged.yaml: Failed to yaml decode (error: line 1 column 17: unsupported tag `!reference`
--> <input>:1:17
|
1 | foo: !reference [.bar, script]
| ^ unsupported tag `!reference`)
"#);

let result = check_syntax(filename, content);
assert_eq!((result.exit_status, result.output), (0, Vec::new()));
}

#[tokio::test]
async fn test_yaml_with_binary_scalar() -> Result<()> {
let dir = tempdir()?;
Expand Down
Loading