Skip to content

Commit d96c7ed

Browse files
committed
Add --help for Cli and selected tests
1 parent 6236c1b commit d96c7ed

5 files changed

Lines changed: 30 additions & 14 deletions

File tree

README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,25 @@ dotnet run --project src/Http11Probe.Cli -- --host localhost --port 8080
4242

4343
| Flag | Description | Default |
4444
|------|-------------|---------|
45-
| `--host` | Target host | `localhost` |
46-
| `--port` | Target port | `8080` |
47-
| `--category` | Filter by category (`Compliance`, `Smuggling`, `MalformedInput`) | all |
48-
| `--timeout` | Connect/read timeout in seconds | `5` |
49-
| `--output` | Write JSON report to file ||
45+
| `--host` | Target hostname or IP address | `localhost` |
46+
| `--port` | Target port number | `8080` |
47+
| `--category` | Run only tests in this category (`Compliance`, `Smuggling`, `MalformedInput`) | all |
48+
| `--test` | Run only specific test IDs, case-insensitive (repeatable) | all |
49+
| `--timeout` | Connect and read timeout in seconds per test | `5` |
50+
| `--output` | Write JSON results to file ||
5051

51-
### Example
52+
### Examples
5253

5354
```
5455
dotnet run --project src/Http11Probe.Cli -- --host localhost --port 8080 --output results.json
5556
```
5657

58+
Run specific tests:
59+
60+
```
61+
dotnet run --project src/Http11Probe.Cli -- --test SMUG-CL-TE-BOTH --test SMUG-DUPLICATE-CL
62+
```
63+
5764
Results stream to the console as each test completes, with a summary at the end:
5865

5966
```

src/Http11Probe.Cli/Program.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,27 @@
44
using Http11Probe.TestCases;
55
using Http11Probe.TestCases.Suites;
66

7-
var hostOption = new Option<string>("--host") { Description = "Target host" };
7+
var hostOption = new Option<string>("--host") { Description = "Target hostname or IP address" };
88
hostOption.DefaultValueFactory = _ => "localhost";
99

10-
var portOption = new Option<int>("--port") { Description = "Target port" };
10+
var portOption = new Option<int>("--port") { Description = "Target port number" };
1111
portOption.DefaultValueFactory = _ => 8080;
1212

13-
var categoryOption = new Option<TestCategory?>("--category") { Description = "Run only tests in this category" };
13+
var categoryOption = new Option<TestCategory?>("--category") { Description = "Run only tests in this category (skip all others)" };
1414

15-
var timeoutOption = new Option<int>("--timeout") { Description = "Read/connect timeout in seconds" };
15+
var testOption = new Option<string[]>("--test") { Description = "Run only specific test IDs, case-insensitive (repeatable)", Arity = ArgumentArity.OneOrMore };
16+
17+
var timeoutOption = new Option<int>("--timeout") { Description = "Connect and read timeout in seconds per test" };
1618
timeoutOption.DefaultValueFactory = _ => 5;
1719

18-
var outputOption = new Option<string?>("--output") { Description = "Write JSON report to this file path" };
20+
var outputOption = new Option<string?>("--output") { Description = "Write JSON results to this file path" };
1921

2022
var rootCommand = new RootCommand("Http11Probe — HTTP/1.1 server compliance & hardening tester")
2123
{
2224
hostOption,
2325
portOption,
2426
categoryOption,
27+
testOption,
2528
timeoutOption,
2629
outputOption
2730
};
@@ -32,6 +35,7 @@
3235
var port = parseResult.GetValue(portOption);
3336
var category = parseResult.GetValue(categoryOption);
3437
var timeout = parseResult.GetValue(timeoutOption);
38+
var testIds = parseResult.GetValue(testOption);
3539
var outputPath = parseResult.GetValue(outputOption);
3640

3741
Console.WriteLine($" Http11Probe targeting {host}:{port}");
@@ -43,7 +47,10 @@
4347
Port = port,
4448
ConnectTimeout = TimeSpan.FromSeconds(timeout),
4549
ReadTimeout = TimeSpan.FromSeconds(timeout),
46-
CategoryFilter = category
50+
CategoryFilter = category,
51+
TestIdFilter = testIds is { Length: > 0 }
52+
? new HashSet<string>(testIds, StringComparer.OrdinalIgnoreCase)
53+
: null
4754
};
4855

4956
var testCases = ComplianceSuite.GetTestCases()

src/Http11Probe/Runner/TestRunOptions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ public sealed class TestRunOptions
99
public TimeSpan ConnectTimeout { get; init; } = TimeSpan.FromSeconds(5);
1010
public TimeSpan ReadTimeout { get; init; } = TimeSpan.FromSeconds(5);
1111
public TestCategory? CategoryFilter { get; init; }
12+
public HashSet<string>? TestIdFilter { get; init; }
1213
}

src/Http11Probe/Runner/TestRunner.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ public async Task<TestRunReport> RunAsync(IEnumerable<TestCase> testCases, Actio
2727

2828
foreach (var testCase in testCases)
2929
{
30-
if (_options.CategoryFilter.HasValue && testCase.Category != _options.CategoryFilter.Value)
30+
if (_options.CategoryFilter.HasValue && testCase.Category != _options.CategoryFilter.Value
31+
|| _options.TestIdFilter is { Count: > 0 } ids && !ids.Contains(testCase.Id))
3132
{
3233
var skip = new TestResult
3334
{

src/Servers/GlyphServer/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
using Glyph11.Protocol;
99
using Glyph11.Validation;
1010

11-
var port = args.Length > 0 && int.TryParse(args[0], out var p) ? p : 5098;
11+
var port = args.Length > 0 && int.TryParse(args[0], out var p) ? p : 8080;
1212

1313
var listener = new TcpListener(IPAddress.Any, port);
1414
listener.Start();

0 commit comments

Comments
 (0)