Skip to content

Commit 248ac41

Browse files
committed
Add integration test for HTML injection through regex literal in HTML report.
1 parent 7dcdbd1 commit 248ac41

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<pre><code class="language-hurl"><span class="entry"><span class="request"><span class="comment"># This file checks that regex literal are well escaped and forbid JavaScript injections.</span>
2+
<span class="method">GET</span> <span class="url">https://foo.com</span>
3+
</span><span class="response"><span class="version">HTTP</span> <span class="number">200</span>
4+
<span class="section-header">[Asserts]</span>
5+
<span class="query-type">jsonpath</span> <span class="string">"$.body"</span> <span class="predicate-type">matches</span> <span class="regex">/&lt;img src="" onerror="alert('Hi!')"&gt;/</span>
6+
</span></span></code></pre>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# This file checks that regex literal are well escaped and forbid JavaScript injections.
2+
GET https://foo.com
3+
HTTP 200
4+
[Asserts]
5+
jsonpath "$.body" matches /<img src="" onerror="alert('Hi!')">/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"entries":[{"request":{"method":"GET","url":"https://foo.com","comments":[" This file checks that regex literal are well escaped and forbid JavaScript injections."]},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$.body"},"predicate":{"type":"matches","value":"<img src=\"\" onerror=\"alert('Hi!')\">","encoding":"regex"}}]}}]}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# This file checks that regex literal are well escaped and forbid JavaScript injections.
2+
GET https://foo.com
3+
HTTP 200
4+
[Asserts]
5+
jsonpath "$.body" matches /<img src="" onerror="alert('Hi!')">/

packages/hurl_core/src/ast/visit.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Hurl (https://hurl.dev)
3-
* Copyright (C) 2024 Orange
3+
* Copyright (C) 2025 Orange
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -18,6 +18,8 @@
1818
//! Walker traverses an AST in depth-first order. Each overridden visit method has full control over
1919
//! what happens with its node, it can do its own traversal of the node's children, call `visit::walk_*`
2020
//! to apply the default traversal algorithm, or prevent deeper traversal by doing nothing.
21+
//!
22+
//! Code heavily inspired from <https://github.com/rust-lang/rust/blob/master/compiler/rustc_ast/src/visit.rs>
2123
use crate::ast::{
2224
Assert, Base64, Body, BooleanOption, Bytes, Capture, Comment, Cookie, CookiePath, CountOption,
2325
DurationOption, Entry, EntryOption, File, FilenameParam, FilenameValue, Filter, FilterValue,

0 commit comments

Comments
 (0)