Skip to content

Commit 18c2f31

Browse files
Upgrade junit-report crate to 0.8 version (#229, #226)
Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: ilslv <[email protected]>
1 parent ad0bb22 commit 18c2f31

File tree

6 files changed

+45
-31
lines changed

6 files changed

+45
-31
lines changed

.editorconfig

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ indent_size = 4
2929
indent_style = space
3030
indent_size = 2
3131

32+
[*.xml]
33+
indent_style = space
34+
indent_size = 2
35+
3236
[Makefile]
3337
indent_style = tab
3438
indent_size = 4

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@ All user visible changes to `cucumber` crate will be documented in this file. Th
1919

2020
- `CARGO_MANIFEST_DIR` being detected in compile time. ([todo])
2121

22+
### Security updated
23+
24+
- `junit-report` crate to 0.8 version to fix [RUSTSEC-2022-0048]. ([#229], [#226])
25+
26+
[#226]: /../../issues/226
27+
[#229]: /../../pull/229
2228
[todo]: /../../commit/todo
29+
[RUSTSEC-2022-0048]: https://rustsec.org/advisories/RUSTSEC-2022-0048.html
2330

2431

2532

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ serde_json = { version = "1.0.18", optional = true }
6868
Inflector = { version = "0.11", default-features = false, optional = true }
6969

7070
# "output-junit" feature dependencies.
71-
junit-report = { version = "0.7", optional = true }
71+
junit-report = { version = "0.8", optional = true }
7272

7373
[dev-dependencies]
7474
derive_more = "0.99.17"

src/writer/junit.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//!
1313
//! [1]: https://llg.cubic.org/docs/junit
1414
15-
use std::{fmt::Debug, io, mem, path::Path, time::SystemTime};
15+
use std::{fmt::Debug, io, mem, time::SystemTime};
1616

1717
use async_trait::async_trait;
1818
use junit_report::{
@@ -23,7 +23,7 @@ use crate::{
2323
event, parser,
2424
writer::{
2525
self,
26-
basic::{coerce_error, Coloring},
26+
basic::{coerce_error, trim_path, Coloring},
2727
discard,
2828
out::WritableString,
2929
Ext as _, Verbosity,
@@ -116,7 +116,7 @@ where
116116
&feat.name,
117117
feat.path
118118
.as_deref()
119-
.and_then(Path::to_str)
119+
.and_then(|p| p.to_str().map(trim_path))
120120
.map(|path| format!(": {path}"))
121121
.unwrap_or_default(),
122122
))
@@ -225,7 +225,7 @@ impl<W: Debug, Out: io::Write> JUnit<W, Out> {
225225
format!(
226226
"Feature{}",
227227
path.to_str()
228-
.map(|p| format!(": {p}"))
228+
.map(|p| format!(": {}", trim_path(p)))
229229
.unwrap_or_default(),
230230
),
231231
"Parser Error",
@@ -236,7 +236,7 @@ impl<W: Debug, Out: io::Write> JUnit<W, Out> {
236236
"Feature: {}{}:{}",
237237
err.path
238238
.as_deref()
239-
.and_then(Path::to_str)
239+
.and_then(|p| p.to_str().map(trim_path))
240240
.map(|p| format!("{p}:"))
241241
.unwrap_or_default(),
242242
err.pos.line,
@@ -335,7 +335,7 @@ impl<W: Debug, Out: io::Write> JUnit<W, Out> {
335335
sc.name,
336336
feat.path
337337
.as_ref()
338-
.and_then(|p| p.to_str())
338+
.and_then(|p| p.to_str().map(trim_path))
339339
.map(|path| format!("{path}:"))
340340
.unwrap_or_default(),
341341
sc.position.line,

tests/junit.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::{fs, io::Read as _};
22

33
use cucumber::{given, then, when, writer, World as _};
4-
use regex::Regex;
4+
use regex::RegexBuilder;
55
use tempfile::NamedTempFile;
66

77
#[given(regex = r"(\d+) secs?")]
@@ -27,11 +27,14 @@ async fn main() {
2727

2828
// Required to strip out non-deterministic parts of output, so we could
2929
// compare them well.
30-
let non_deterministic = Regex::new(
30+
let non_deterministic = RegexBuilder::new(
3131
"time(stamp)?=\"[^\"]+\"\
32-
|([^\"\\n\\s]*)[/\\\\]([A-z1-9-_]*)\\.(feature|rs)(:\\d+:\\d+)?\
33-
|\\s?\n",
32+
|: [^\\.\\s]*\\.(feature|rs)(:\\d+:\\d+)?\
33+
|^\\s+\
34+
|\\s?\\n",
3435
)
36+
.multi_line(true)
37+
.build()
3538
.unwrap();
3639

3740
assert_eq!(

tests/junit/correct.xml

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<testsuites>
33
<testsuite id="0" name="Errors" package="testsuite/Errors" tests="1" errors="0" failures="1" hostname="localhost" timestamp="2022-03-29T07:22:01.580122Z" time="0">
4-
<testcase name="Feature: /tests/features/wait/invalid.feature" time="0">
5-
<failure type="Parser Error" message="Failed to parse feature: Could not parse feature file: /tests/features/wait/invalid.feature" />
4+
<testcase name="Feature: tests/features/wait/invalid.feature" time="0">
5+
<failure type="Parser Error" message="Failed to parse feature: Could not parse feature file: tests/features/wait/invalid.feature"/>
66
</testcase>
77
</testsuite>
8-
<testsuite id="1" name="Feature: Basic: /tests/features/wait/rule.feature" package="testsuite/Feature: Basic: /tests/features/wait/rule.feature" tests="2" errors="0" failures="1" hostname="localhost" timestamp="2022-03-29T07:22:01.574719Z" time="0.000673">
9-
<testcase name="Scenario: 1 sec: /tests/features/wait/rule.feature:6:3" time="0">
10-
<skipped />
8+
<testsuite id="1" name="Feature: Basic: tests/features/wait/rule.feature" package="testsuite/Feature: Basic: tests/features/wait/rule.feature" tests="2" errors="0" failures="1" hostname="localhost" timestamp="2022-03-29T07:22:01.574719Z" time="0.000673">
9+
<testcase name="Scenario: 1 sec: tests/features/wait/rule.feature:6:3" time="0">
10+
<skipped/>
1111
</testcase>
12-
<testcase name="Rule: rule: Scenario: 2 secs: /tests/features/wait/rule.feature:14:5" time="0.000673">
12+
<testcase name="Rule: rule: Scenario: 2 secs: tests/features/wait/rule.feature:14:5" time="0.000673">
1313
<failure type="Step Panicked" message="Step panicked. Captured output: Too much!"><![CDATA[ Scenario: 2 secs
1414
✔> Given 1 sec
1515
✔ Given 2 secs
@@ -25,11 +25,11 @@
2525
]]></failure>
2626
</testcase>
2727
</testsuite>
28-
<testsuite id="2" name="Feature: Basic: /tests/features/wait/nested/rule.feature" package="testsuite/Feature: Basic: /tests/features/wait/nested/rule.feature" tests="2" errors="0" failures="1" hostname="localhost" timestamp="2022-03-29T07:22:01.576081Z" time="0.000137">
29-
<testcase name="Scenario: 1 sec: /tests/features/wait/nested/rule.feature:6:3" time="0">
30-
<skipped />
28+
<testsuite id="2" name="Feature: Basic: tests/features/wait/nested/rule.feature" package="testsuite/Feature: Basic: tests/features/wait/nested/rule.feature" tests="2" errors="0" failures="1" hostname="localhost" timestamp="2022-03-29T07:22:01.576081Z" time="0.000137">
29+
<testcase name="Scenario: 1 sec: tests/features/wait/nested/rule.feature:6:3" time="0">
30+
<skipped/>
3131
</testcase>
32-
<testcase name="Rule: rule: Scenario: 2 secs: /tests/features/wait/nested/rule.feature:14:5" time="0.000137">
32+
<testcase name="Rule: rule: Scenario: 2 secs: tests/features/wait/nested/rule.feature:14:5" time="0.000137">
3333
<failure type="Step Panicked" message="Step panicked. Captured output: Too much!"><![CDATA[ Scenario: 2 secs
3434
✔> Given 1 sec
3535
✔ Given 2 secs
@@ -45,59 +45,59 @@
4545
]]></failure>
4646
</testcase>
4747
</testsuite>
48-
<testsuite id="3" name="Feature: Outline: /tests/features/wait/outline.feature" package="testsuite/Feature: Outline: /tests/features/wait/outline.feature" tests="4" errors="0" failures="0" hostname="localhost" timestamp="2022-03-29T07:22:01.576909Z" time="0.00034">
49-
<testcase name="Scenario: wait: /tests/features/wait/outline.feature:14:5" time="0.000085">
48+
<testsuite id="3" name="Feature: Outline: tests/features/wait/outline.feature" package="testsuite/Feature: Outline: tests/features/wait/outline.feature" tests="4" errors="0" failures="0" hostname="localhost" timestamp="2022-03-29T07:22:01.576909Z" time="0.00034">
49+
<testcase name="Scenario: wait: tests/features/wait/outline.feature:14:5" time="0.000085">
5050
<system-out><![CDATA[ Scenario Outline: wait
5151
✔ Given 2 secs
5252
✔ When 2 secs
5353
✔ Then 2 secs
5454
]]></system-out>
5555
</testcase>
56-
<testcase name="Scenario: wait: /tests/features/wait/outline.feature:15:5" time="0.000081">
56+
<testcase name="Scenario: wait: tests/features/wait/outline.feature:15:5" time="0.000081">
5757
<system-out><![CDATA[ Scenario Outline: wait
5858
✔ Given 1 secs
5959
✔ When 1 secs
6060
✔ Then 1 secs
6161
]]></system-out>
6262
</testcase>
63-
<testcase name="Scenario: wait: /tests/features/wait/outline.feature:16:5" time="0.000093">
63+
<testcase name="Scenario: wait: tests/features/wait/outline.feature:16:5" time="0.000093">
6464
<system-out><![CDATA[ Scenario Outline: wait
6565
✔ Given 1 secs
6666
✔ When 1 secs
6767
✔ Then 1 secs
6868
]]></system-out>
6969
</testcase>
70-
<testcase name="Scenario: wait: /tests/features/wait/outline.feature:21:5" time="0.000081">
70+
<testcase name="Scenario: wait: tests/features/wait/outline.feature:21:5" time="0.000081">
7171
<system-out><![CDATA[ Scenario Outline: wait
7272
✔ Given 5 secs
7373
✔ When 5 secs
7474
✔ Then 5 secs
7575
]]></system-out>
7676
</testcase>
7777
</testsuite>
78-
<testsuite id="4" name="Feature: Rule Outline: /tests/features/wait/rule_outline.feature" package="testsuite/Feature: Rule Outline: /tests/features/wait/rule_outline.feature" tests="4" errors="0" failures="0" hostname="localhost" timestamp="2022-03-29T07:22:01.576911Z" time="0.000336">
79-
<testcase name="Rule: To them all: Scenario: wait: /tests/features/wait/rule_outline.feature:11:7" time="0.000082">
78+
<testsuite id="4" name="Feature: Rule Outline: tests/features/wait/rule_outline.feature" package="testsuite/Feature: Rule Outline: tests/features/wait/rule_outline.feature" tests="4" errors="0" failures="0" hostname="localhost" timestamp="2022-03-29T07:22:01.576911Z" time="0.000336">
79+
<testcase name="Rule: To them all: Scenario: wait: tests/features/wait/rule_outline.feature:11:7" time="0.000082">
8080
<system-out><![CDATA[ Scenario Outline: wait
8181
✔ Given 2 secs
8282
✔ When 2 secs
8383
✔ Then 2 secs
8484
]]></system-out>
8585
</testcase>
86-
<testcase name="Rule: To them all: Scenario: wait: /tests/features/wait/rule_outline.feature:12:7" time="0.000086">
86+
<testcase name="Rule: To them all: Scenario: wait: tests/features/wait/rule_outline.feature:12:7" time="0.000086">
8787
<system-out><![CDATA[ Scenario Outline: wait
8888
✔ Given 1 secs
8989
✔ When 1 secs
9090
✔ Then 1 secs
9191
]]></system-out>
9292
</testcase>
93-
<testcase name="Rule: To them all: Scenario: wait: /tests/features/wait/rule_outline.feature:13:7" time="0.000086">
93+
<testcase name="Rule: To them all: Scenario: wait: tests/features/wait/rule_outline.feature:13:7" time="0.000086">
9494
<system-out><![CDATA[ Scenario Outline: wait
9595
✔ Given 1 secs
9696
✔ When 1 secs
9797
✔ Then 1 secs
9898
]]></system-out>
9999
</testcase>
100-
<testcase name="Rule: To them all: Scenario: wait: /tests/features/wait/rule_outline.feature:14:7" time="0.000082">
100+
<testcase name="Rule: To them all: Scenario: wait: tests/features/wait/rule_outline.feature:14:7" time="0.000082">
101101
<system-out><![CDATA[ Scenario Outline: wait
102102
✔ Given 5 secs
103103
✔ When 5 secs

0 commit comments

Comments
 (0)