mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 18:13:42 +00:00
Formats code comments as sentences in the tests.
Capitalizes the first word and adds the terminal period in the unit, integration and security tests. The AAA markers stay bare, the TODO bodies stay lowercase, and no assertion, payload, expected status code or test signature changes.
This commit is contained in:
1 parent
727aa33318
commit
057f557791
540 files changed
+3888
-3888
No files matched your search
+7
-7
@@ -62,12 +62,12 @@ public class GetLibraryArtworkProvidersEndpointTests : IClassFixture<LuminaApiFa
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("' OR '1'='1")] // basic SQL injection
|
||||
[InlineData("'; DROP TABLE Libraries--")] // destructive injection
|
||||
[InlineData("' OR '1'='1")] // Basic SQL injection.
|
||||
[InlineData("'; DROP TABLE Libraries--")] // Destructive injection.
|
||||
public async Task GetLibraryArtworkProviders_WithSQLInjectionInLibraryId_ShouldNotLeakOrError(string maliciousLibraryId)
|
||||
{
|
||||
// Arrange
|
||||
// authenticate with an admin user and seed a library with an artwork provider configuration, so a valid id would reach the handler
|
||||
// Authenticate with an admin user and seed a library with an artwork provider configuration, so a valid id would reach the handler.
|
||||
HttpClient client = _apiFactory.CreateClient();
|
||||
Guid userId = await _apiFactory.CreateAndAuthenticateAdminUserAsync(client);
|
||||
Guid libraryId = await SeedLibraryAsync(userId);
|
||||
@@ -77,10 +77,10 @@ public class GetLibraryArtworkProvidersEndpointTests : IClassFixture<LuminaApiFa
|
||||
HttpResponseMessage response = await client.GetAsync($"/api/v1/libraries/{Uri.EscapeDataString(maliciousLibraryId)}/artwork-providers");
|
||||
|
||||
// Assert
|
||||
// note: the {libraryId} route parameter is Guid-typed, so the malicious value fails model binding before it reaches the handler
|
||||
// note: observed status is 500 because FastEndpoints, combined with DontCatchExceptions(), turns the binding
|
||||
// ValidationFailureException into a 500 response instead of 400/422 (pre-existing production bug, not fixed here)
|
||||
// note: that 500 body leaks the ValidationFailureException details, so no DoesNotContain("Exception") is asserted here
|
||||
// Note: the {libraryId} route parameter is Guid-typed, so the malicious value fails model binding before it reaches the handler.
|
||||
// Note: observed status is 500 because FastEndpoints, combined with DontCatchExceptions(), turns the binding
|
||||
// ValidationFailureException into a 500 response instead of 400/422 (pre-existing production bug, not fixed here).
|
||||
// Note: that 500 body leaks the ValidationFailureException details, so no DoesNotContain("Exception") is asserted here.
|
||||
Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode);
|
||||
string content = await response.Content.ReadAsStringAsync();
|
||||
Assert.DoesNotContain("SqliteException", content, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
+3
-3
@@ -52,8 +52,8 @@ public class GetLibraryBookReadersEndpointTests : IClassFixture<LuminaApiFactory
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("' OR '1'='1")] // basic SQL injection
|
||||
[InlineData("'; DROP TABLE Libraries--")] // destructive injection
|
||||
[InlineData("' OR '1'='1")] // Basic SQL injection.
|
||||
[InlineData("'; DROP TABLE Libraries--")] // Destructive injection.
|
||||
public async Task GetLibraryBookReaders_WithSQLInjectionInLibraryId_ShouldNotLeakDatabaseDetails(string maliciousLibraryId)
|
||||
{
|
||||
// Act
|
||||
@@ -61,7 +61,7 @@ public class GetLibraryBookReadersEndpointTests : IClassFixture<LuminaApiFactory
|
||||
string content = await response.Content.ReadAsStringAsync();
|
||||
|
||||
// Assert
|
||||
// the {libraryId} route parameter is Guid-typed, so the malicious value fails model binding before it reaches the handler
|
||||
// The {libraryId} route parameter is Guid-typed, so the malicious value fails model binding before it reaches the handler.
|
||||
Assert.DoesNotContain("SqliteException", content, StringComparison.OrdinalIgnoreCase);
|
||||
Assert.DoesNotContain("password", content, StringComparison.OrdinalIgnoreCase);
|
||||
Assert.DoesNotContain("hash", content, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
+7
-7
@@ -62,12 +62,12 @@ public class GetLibraryMetadataProvidersEndpointTests : IClassFixture<LuminaApiF
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("' OR '1'='1")] // basic SQL injection
|
||||
[InlineData("'; DROP TABLE Libraries--")] // destructive injection
|
||||
[InlineData("' OR '1'='1")] // Basic SQL injection.
|
||||
[InlineData("'; DROP TABLE Libraries--")] // Destructive injection.
|
||||
public async Task GetLibraryMetadataProviders_WithSQLInjectionInLibraryId_ShouldNotLeakOrError(string maliciousLibraryId)
|
||||
{
|
||||
// Arrange
|
||||
// authenticate with an admin user and seed a library with a metadata provider configuration, so a valid id would reach the handler
|
||||
// Authenticate with an admin user and seed a library with a metadata provider configuration, so a valid id would reach the handler.
|
||||
HttpClient client = _apiFactory.CreateClient();
|
||||
Guid userId = await _apiFactory.CreateAndAuthenticateAdminUserAsync(client);
|
||||
Guid libraryId = await SeedLibraryAsync(userId);
|
||||
@@ -77,10 +77,10 @@ public class GetLibraryMetadataProvidersEndpointTests : IClassFixture<LuminaApiF
|
||||
HttpResponseMessage response = await client.GetAsync($"/api/v1/libraries/{Uri.EscapeDataString(maliciousLibraryId)}/metadata-providers");
|
||||
|
||||
// Assert
|
||||
// note: the {libraryId} route parameter is Guid-typed, so the malicious value fails model binding before it reaches the handler
|
||||
// note: observed status is 500 because FastEndpoints, combined with DontCatchExceptions(), turns the binding
|
||||
// ValidationFailureException into a 500 response instead of 400/422 (pre-existing production bug, not fixed here)
|
||||
// note: that 500 body leaks the ValidationFailureException details, so no DoesNotContain("Exception") is asserted here
|
||||
// Note: the {libraryId} route parameter is Guid-typed, so the malicious value fails model binding before it reaches the handler.
|
||||
// Note: observed status is 500 because FastEndpoints, combined with DontCatchExceptions(), turns the binding
|
||||
// ValidationFailureException into a 500 response instead of 400/422 (pre-existing production bug, not fixed here).
|
||||
// Note: that 500 body leaks the ValidationFailureException details, so no DoesNotContain("Exception") is asserted here.
|
||||
Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode);
|
||||
string content = await response.Content.ReadAsStringAsync();
|
||||
Assert.DoesNotContain("SqliteException", content, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
+7
-7
@@ -60,12 +60,12 @@ public class GetPluginSettingsEndpointTests : IClassFixture<LuminaApiFactory>
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("' OR '1'='1")] // basic SQL injection
|
||||
[InlineData("'; DROP TABLE Plugins--")] // destructive injection
|
||||
[InlineData("' OR '1'='1")] // Basic SQL injection.
|
||||
[InlineData("'; DROP TABLE Plugins--")] // Destructive injection.
|
||||
public async Task GetPluginSettings_WithSQLInjectionInPluginId_ShouldNotLeakOrError(string maliciousPluginId)
|
||||
{
|
||||
// Arrange
|
||||
// authenticate with an admin user and seed a plugin, so a valid pluginId would reach the handler
|
||||
// Authenticate with an admin user and seed a plugin, so a valid pluginId would reach the handler.
|
||||
HttpClient client = _apiFactory.CreateClient();
|
||||
await _apiFactory.CreateAndAuthenticateAdminUserAsync(client);
|
||||
await SeedPluginAsync();
|
||||
@@ -74,10 +74,10 @@ public class GetPluginSettingsEndpointTests : IClassFixture<LuminaApiFactory>
|
||||
HttpResponseMessage response = await client.GetAsync($"/api/v1/plugins/{Uri.EscapeDataString(maliciousPluginId)}/settings");
|
||||
|
||||
// Assert
|
||||
// note: the {pluginId} route parameter is Guid-typed, so the malicious value fails model binding before it reaches the handler
|
||||
// note: observed status is 500 because FastEndpoints, combined with DontCatchExceptions(), turns the binding
|
||||
// ValidationFailureException into a 500 response instead of 400/422 (pre-existing production bug, not fixed here)
|
||||
// note: that 500 body leaks the ValidationFailureException details, so no DoesNotContain("Exception") is asserted here
|
||||
// Note: the {pluginId} route parameter is Guid-typed, so the malicious value fails model binding before it reaches the handler.
|
||||
// Note: observed status is 500 because FastEndpoints, combined with DontCatchExceptions(), turns the binding
|
||||
// ValidationFailureException into a 500 response instead of 400/422 (pre-existing production bug, not fixed here).
|
||||
// Note: that 500 body leaks the ValidationFailureException details, so no DoesNotContain("Exception") is asserted here.
|
||||
Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode);
|
||||
string content = await response.Content.ReadAsStringAsync();
|
||||
Assert.DoesNotContain("SqliteException", content, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
+2
-2
@@ -117,7 +117,7 @@ public class InstallPluginEndpointTests : IClassFixture<LuminaApiFactory>, IDisp
|
||||
await _apiFactory.CreateAndAuthenticateAdminUserAsync(client);
|
||||
byte[] zipBytes = CreateZipWithEntries(new Dictionary<string, string>
|
||||
{
|
||||
[@"..\evil.dll"] = "evil" // path traversal entry inside the archive
|
||||
[@"..\evil.dll"] = "evil" // Path traversal entry inside the archive.
|
||||
});
|
||||
_installedPluginFileNames.Add("evil.dll");
|
||||
|
||||
@@ -128,7 +128,7 @@ public class InstallPluginEndpointTests : IClassFixture<LuminaApiFactory>, IDisp
|
||||
|
||||
// Assert
|
||||
response.EnsureSuccessStatusCode();
|
||||
// the entry is flattened, so it cannot escape the plugins directory
|
||||
// The entry is flattened, so it cannot escape the plugins directory.
|
||||
Assert.False(File.Exists(Path.Combine(AppContext.BaseDirectory, "evil.dll")));
|
||||
Assert.True(File.Exists(Path.Combine(AppContext.BaseDirectory, "plugins", "evil.dll")));
|
||||
Assert.DoesNotContain("Exception", content, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
+3
-3
@@ -70,8 +70,8 @@ public class UpdatePluginSettingsEndpointTests : IClassFixture<LuminaApiFactory>
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("' OR '1'='1")] // basic SQL injection
|
||||
[InlineData("'; DROP TABLE Plugins--")] // destructive injection
|
||||
[InlineData("' OR '1'='1")] // Basic SQL injection.
|
||||
[InlineData("'; DROP TABLE Plugins--")] // Destructive injection.
|
||||
public async Task UpdatePluginSettings_WithSQLInjectionInSettings_ShouldNotLeakOrError(string maliciousValue)
|
||||
{
|
||||
// Arrange
|
||||
@@ -87,7 +87,7 @@ public class UpdatePluginSettingsEndpointTests : IClassFixture<LuminaApiFactory>
|
||||
HttpResponseMessage response = await client.PutAsJsonAsync($"/api/v1/plugins/{pluginId}/settings", request);
|
||||
|
||||
// Assert
|
||||
// the malicious value passes the authenticated handler, reaches the parameterized data access, and is persisted verbatim
|
||||
// The malicious value passes the authenticated handler, reaches the parameterized data access, and is persisted verbatim.
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
string content = await response.Content.ReadAsStringAsync();
|
||||
Assert.DoesNotContain("SqliteException", content, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
Reference in new issue
Block a user