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
2 changes: 1 addition & 1 deletion src/SecTester.Core/Dispatchers/HttpCommandDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
using System.Threading;
using System.Threading.Tasks;
using SecTester.Core.Bus;
using SecTester.Core.Utils;
using SecTester.Core.Commands;
using SecTester.Core.Extensions;
using SecTester.Core.Utils;

namespace SecTester.Core.Dispatchers;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Net.Http;
using Microsoft.Extensions.DependencyInjection;
using SecTester.Core.Extensions;
using SecTester.Core.Utils;
using SecTester.Repeater.Api;
using SecTester.Repeater.Bus;
using SecTester.Repeater.Runners;
Expand Down
28 changes: 14 additions & 14 deletions src/SecTester.Runner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,23 @@ To start scanning your application, first you have to create a `SecScan` instanc

```csharp
await using var scan = await runner.CreateScan(new ScanSettingsBuilder()
.WithTests(new List<TestType> { TestType.CrossSiteScripting }));
.WithTests(new List<string> { "xss" }));
```

Below you will find a list of parameters that can be used to configure a `Scan`:

| Option | Description |
| ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Target` | The target that will be attacked. For details, see [here](#defining-a-target-for-attack). |
| `Tests` | The list of tests to be performed against the target application. [Learn more about tests](https://docs.brightsec.com/docs/vulnerability-guide) |
| `RepeaterId` | Connects the scan to a Repeater agent, which provides secure access to local networks. |
| `Smart` | Minimize scan time by using automatic smart decisions regarding parameter skipping, detection phases, etc. Enabled by default. |
| `SkipStaticParams` | Use an advanced algorithm to automatically determine if a parameter has any effect on the target system's behavior when changed, and skip testing such static parameters. Enabled by default. |
| `PoolSize` | Sets the maximum concurrent requests for the scan, to control the load on your server. By default, `10`. |
| `AttackParamLocations` | Defines which part of the request to attack. By default, `body`, `query`, and `fragment`. |
| `SlowEpTimeout` | Automatically validate entry-point response time before initiating the vulnerability testing, and reduce scan time by skipping any entry-points that take too long to respond. By default, 1000ms. |
| `TargetTimeout` | Measure timeout responses from the target application globally, and stop the scan if the target is unresponsive for longer than the specified time. By default, 5min. |
| `Name` | The scan name. The method and hostname by default, e.g. `GET example.com`. |
| Option | Description |
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Target` | The target that will be attacked. For details, see [here](#defining-a-target-for-attack). |
| `Tests` | The list of tests to be performed against the target application. To retrieve the complete list, send a request to the [API](https://app.brightsec.com/api/v1/scans/tests). [Learn more about tests](https://docs.brightsec.com/docs/vulnerability-guide). |
| `RepeaterId` | Connects the scan to a Repeater agent, which provides secure access to local networks. |
| `Smart` | Minimize scan time by using automatic smart decisions regarding parameter skipping, detection phases, etc. Enabled by default. |
| `SkipStaticParams` | Use an advanced algorithm to automatically determine if a parameter has any effect on the target system's behavior when changed, and skip testing such static parameters. Enabled by default. |
| `PoolSize` | Sets the maximum concurrent requests for the scan, to control the load on your server. By default, `10`. |
| `AttackParamLocations` | Defines which part of the request to attack. By default, `body`, `query`, and `fragment`. |
| `SlowEpTimeout` | Automatically validate entry-point response time before initiating the vulnerability testing, and reduce scan time by skipping any entry-points that take too long to respond. By default, 1000ms. |
| `TargetTimeout` | Measure timeout responses from the target application globally, and stop the scan if the target is unresponsive for longer than the specified time. By default, 5min. |
| `Name` | The scan name. The method and hostname by default, e.g. `GET example.com`. |

We provide a fluent interface for building a `ScanSettings` object. To use it, you start by creating a `ScanSettingsBuilder` instance, and then you call its methods to specify the various settings you want to use for the scan as shown above.

Expand Down Expand Up @@ -162,7 +162,7 @@ public class OrdersApiTests : IClassFixture<SecRunnerFixture>, IAsyncDisposable
_test = _fixture
.Runner
.CreateScan(new ScanSettingsBuilder()
.WithTests(new List<TestType> { TestType.CrossSiteScripting }))
.WithTests(new List<string> { "xss" }))
.Threshold(Severity.Medium)
.Timeout(TimeSpan.FromMinutes(5));
}
Expand Down
2 changes: 1 addition & 1 deletion src/SecTester.Scan/Models/ScanConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public record ScanConfig(string Name)
{
public string Name { get; } = Name ?? throw new ArgumentNullException(nameof(Name));
public Module? Module { get; init; }
public IEnumerable<TestType>? Tests { get; init; }
public IEnumerable<string>? Tests { get; init; }
public IEnumerable<Discovery>? DiscoveryTypes { get; init; }
public int? PoolSize { get; init; }
public IEnumerable<AttackParamLocation>? AttackParamLocations { get; init; }
Expand Down
136 changes: 0 additions & 136 deletions src/SecTester.Scan/Models/TestType.cs

This file was deleted.

26 changes: 13 additions & 13 deletions src/SecTester.Scan/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@ The factory exposes the `CreateScan` method that returns a new [Scan instance](#
```csharp
await using var result = scanFactory.CreateScan(new ScanSettings(
target,
new List<TestType>() { TestType.CrossSiteScripting }));
new List<string>() { "xss" }));
```

Below you will find a list of parameters that can be used to configure a `Scan`:

| Option | Description |
| ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Target` | The target that will be attacked. For details, see [here](#defining-a-target-for-attack). |
| `Tests` | The list of tests to be performed against the target application. [Learn more about tests](https://docs.brightsec.com/docs/vulnerability-guide) |
| `RepeaterId` | Connects the scan to a Repeater agent, which provides secure access to local networks. |
| `Smart` | Minimize scan time by using automatic smart decisions regarding parameter skipping, detection phases, etc. Enabled by default. |
| `SkipStaticParams` | Use an advanced algorithm to automatically determine if a parameter has any effect on the target system's behavior when changed, and skip testing such static parameters. Enabled by default. |
| `PoolSize` | Sets the maximum concurrent requests for the scan, to control the load on your server. By default, `10`. |
| `AttackParamLocations` | Defines which part of the request to attack. By default, `body`, `query`, and `fragment`. |
| `SlowEpTimeout` | Automatically validate entry-point response time before initiating the vulnerability testing, and reduce scan time by skipping any entry-points that take too long to respond. By default, 1000ms. |
| `TargetTimeout` | Measure timeout responses from the target application globally, and stop the scan if the target is unresponsive for longer than the specified time. By default, 5min. |
| `Name` | The scan name. The method and hostname by default, e.g. `GET example.com`. |
| Option | Description |
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Target` | The target that will be attacked. For details, see [here](#defining-a-target-for-attack). |
| `Tests` | The list of tests to be performed against the target application. To retrieve the complete list, send a request to the [API](https://app.brightsec.com/api/v1/scans/tests). [Learn more about tests](https://docs.brightsec.com/docs/vulnerability-guide). |
| `RepeaterId` | Connects the scan to a Repeater agent, which provides secure access to local networks. |
| `Smart` | Minimize scan time by using automatic smart decisions regarding parameter skipping, detection phases, etc. Enabled by default. |
| `SkipStaticParams` | Use an advanced algorithm to automatically determine if a parameter has any effect on the target system's behavior when changed, and skip testing such static parameters. Enabled by default. |
| `PoolSize` | Sets the maximum concurrent requests for the scan, to control the load on your server. By default, `10`. |
| `AttackParamLocations` | Defines which part of the request to attack. By default, `body`, `query`, and `fragment`. |
| `SlowEpTimeout` | Automatically validate entry-point response time before initiating the vulnerability testing, and reduce scan time by skipping any entry-points that take too long to respond. By default, 1000ms. |
| `TargetTimeout` | Measure timeout responses from the target application globally, and stop the scan if the target is unresponsive for longer than the specified time. By default, 5min. |
| `Name` | The scan name. The method and hostname by default, e.g. `GET example.com`. |

We provide a fluent interface for building a `ScanSettings` object. To use it, you start by creating a `ScanSettingsBuilder` instance, and then you call its methods to specify the various settings you want to use for the scan.

Expand Down
11 changes: 3 additions & 8 deletions src/SecTester.Scan/ScanSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
private readonly int? _poolSize;
private readonly TimeSpan? _slowEpTimeout;
private readonly TimeSpan? _targetTimeout;
private readonly IEnumerable<TestType> _tests;
private readonly IEnumerable<string> _tests;
private readonly Target _target;

public ScanSettings(string name, Target target, IEnumerable<TestType> tests)
public ScanSettings(string name, Target target, IEnumerable<string> tests)

Check warning on line 26 in src/SecTester.Scan/ScanSettings.cs

View workflow job for this annotation

GitHub Actions / coverage

Non-nullable field '_name' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 26 in src/SecTester.Scan/ScanSettings.cs

View workflow job for this annotation

GitHub Actions / coverage

Non-nullable field '_tests' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 26 in src/SecTester.Scan/ScanSettings.cs

View workflow job for this annotation

GitHub Actions / coverage

Non-nullable field '_target' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 26 in src/SecTester.Scan/ScanSettings.cs

View workflow job for this annotation

GitHub Actions / ubuntu-latest

Non-nullable field '_name' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 26 in src/SecTester.Scan/ScanSettings.cs

View workflow job for this annotation

GitHub Actions / ubuntu-latest

Non-nullable field '_tests' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 26 in src/SecTester.Scan/ScanSettings.cs

View workflow job for this annotation

GitHub Actions / ubuntu-latest

Non-nullable field '_target' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 26 in src/SecTester.Scan/ScanSettings.cs

View workflow job for this annotation

GitHub Actions / windows-latest

Non-nullable field '_name' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 26 in src/SecTester.Scan/ScanSettings.cs

View workflow job for this annotation

GitHub Actions / windows-latest

Non-nullable field '_tests' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 26 in src/SecTester.Scan/ScanSettings.cs

View workflow job for this annotation

GitHub Actions / windows-latest

Non-nullable field '_target' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 26 in src/SecTester.Scan/ScanSettings.cs

View workflow job for this annotation

GitHub Actions / macos-latest

Non-nullable field '_name' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 26 in src/SecTester.Scan/ScanSettings.cs

View workflow job for this annotation

GitHub Actions / macos-latest

Non-nullable field '_tests' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 26 in src/SecTester.Scan/ScanSettings.cs

View workflow job for this annotation

GitHub Actions / macos-latest

Non-nullable field '_target' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
{
Name = name;
Target = target;
Expand Down Expand Up @@ -132,7 +132,7 @@
/// <summary>
/// The list of tests to be performed against the target application
/// </summary>
public IEnumerable<TestType> Tests
public IEnumerable<string> Tests
{
get => _tests;
init
Expand All @@ -142,11 +142,6 @@
throw new ArgumentNullException(nameof(Tests));
}

if (value.Any(x => !Enum.IsDefined(typeof(TestType), x)))
{
throw new ArgumentException("Unknown test type supplied.");
}

var unique = value.Distinct().ToArray();

if (!unique.Any())
Expand Down
4 changes: 2 additions & 2 deletions src/SecTester.Scan/ScanSettingsBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ScanSettingsBuilder
private bool _smart = true;
private Target? _target;
private TimeSpan _targetTimeout = TimeSpan.FromMinutes(5);
private IEnumerable<TestType> _tests = new List<TestType>();
private IEnumerable<string> _tests = new List<string>();

/// <summary>
/// Sets a target for the scan.
Expand Down Expand Up @@ -103,7 +103,7 @@ public ScanSettingsBuilder WithTargetTimeout(TimeSpan value)
/// <summary>
/// Sets a list of tests to run for the scan.
/// </summary>
public ScanSettingsBuilder WithTests(IEnumerable<TestType> value)
public ScanSettingsBuilder WithTests(IEnumerable<string> value)
{
_tests = value;
return this;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Net;
using System.Text;

namespace SecTester.Core.Tests.Extensions;

Expand Down
3 changes: 1 addition & 2 deletions test/SecTester.Core.Tests/Usings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
global using SecTester.Core.Dispatchers;
global using SecTester.Core.Exceptions;
global using SecTester.Core.Extensions;
global using SecTester.Core.RetryStrategies;
global using SecTester.Core.Exceptions;
global using SecTester.Core.Logger;
global using SecTester.Core.RetryStrategies;
global using SecTester.Core.Utils;
global using Xunit;
Loading
Loading