diff --git a/docs/PhishLabsIncidentReporter.md b/docs/PhishLabsIncidentReporter.md index a2b040a..acc5603 100644 --- a/docs/PhishLabsIncidentReporter.md +++ b/docs/PhishLabsIncidentReporter.md @@ -28,9 +28,9 @@ Add the PhishLabs settings to your `appsettings.json`: ```json { "PhishLabs": { - "ApiBaseUrl": "https://api.phishlabs.com", + "ApiBaseUrl": "https://caseapi.phishlabs.com", "ApiKey": "your-api-key-here", - "ServicePath": "/incidents/your-service", + "ServicePath": "/v1/create", "TimeoutSeconds": 30, "MaxRetries": 3, "RateLimitPerMinute": 10 diff --git a/src/UmbracoWeb/UmbracoWeb.Tests/UmbracoWeb.Tests.csproj b/src/UmbracoWeb/UmbracoWeb.Tests/UmbracoWeb.Tests.csproj index 76680cd..1367bcf 100644 --- a/src/UmbracoWeb/UmbracoWeb.Tests/UmbracoWeb.Tests.csproj +++ b/src/UmbracoWeb/UmbracoWeb.Tests/UmbracoWeb.Tests.csproj @@ -14,8 +14,8 @@ - - + + diff --git a/src/UmbracoWeb/UmbracoWeb.Tests/UnitTest1.cs b/src/UmbracoWeb/UmbracoWeb.Tests/UnitTest1.cs index 5c3fbd5..cfcca0a 100644 --- a/src/UmbracoWeb/UmbracoWeb.Tests/UnitTest1.cs +++ b/src/UmbracoWeb/UmbracoWeb.Tests/UnitTest1.cs @@ -28,9 +28,9 @@ public void SetUp() _settings = new PhishLabsSettings { - ApiBaseUrl = "https://api.phishlabs.com", + ApiBaseUrl = "https://caseapi.phishlabs.com", ApiKey = "test-key", - ServicePath = "/incidents/test", + ServicePath = "/v1/create", TimeoutSeconds = 30, MaxRetries = 3, RateLimitPerMinute = 10 @@ -61,8 +61,8 @@ public async Task SubmitIncidentAsync_WithValidRequest_ReturnsSuccessResponse() var apiResponse = new { success = true, - incidentId = "incident-456", - message = "Incident created successfully" + caseId = "case-456", + message = "Case created successfully" }; var responseContent = JsonSerializer.Serialize(apiResponse, new JsonSerializerOptions diff --git a/src/UmbracoWeb/UmbracoWeb/Models/PhishLabsModels.cs b/src/UmbracoWeb/UmbracoWeb/Models/PhishLabsModels.cs index df1019b..313a5a6 100644 --- a/src/UmbracoWeb/UmbracoWeb/Models/PhishLabsModels.cs +++ b/src/UmbracoWeb/UmbracoWeb/Models/PhishLabsModels.cs @@ -49,23 +49,23 @@ public class PhishLabsIncidentResponse } /// -/// Internal model for PhishLabs API request +/// Internal model for PhishLabs Case Creation API request /// internal class PhishLabsApiRequest { - public string Url { get; set; } = string.Empty; - public string? Description { get; set; } + public string CaseType { get; set; } = "Phishing"; + public string Title { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; public string Source { get; set; } = "umbraco-web"; - public DateTime Timestamp { get; set; } = DateTime.UtcNow; } /// -/// Internal model for PhishLabs API response +/// Internal model for PhishLabs Case Creation API response /// internal class PhishLabsApiResponse { public bool Success { get; set; } - public string? IncidentId { get; set; } + public string? CaseId { get; set; } public string? Message { get; set; } public string? Error { get; set; } } \ No newline at end of file diff --git a/src/UmbracoWeb/UmbracoWeb/Services/PhishLabsService.cs b/src/UmbracoWeb/UmbracoWeb/Services/PhishLabsService.cs index 49b9149..bf267fd 100644 --- a/src/UmbracoWeb/UmbracoWeb/Services/PhishLabsService.cs +++ b/src/UmbracoWeb/UmbracoWeb/Services/PhishLabsService.cs @@ -6,7 +6,7 @@ namespace UmbracoWeb.Services; /// -/// Service for integrating with PhishLabs incident reporting API +/// Service for integrating with PhishLabs Case Creation API /// public class PhishLabsService : IPhishLabsService { @@ -52,20 +52,23 @@ public async Task SubmitIncidentAsync( try { + var sanitizedUrl = SanitizeUrl(request.Url); var apiRequest = new PhishLabsApiRequest { - Url = SanitizeUrl(request.Url), - Description = SanitizeDescription(request.Details), - Source = "umbraco-web", - Timestamp = DateTime.UtcNow + CaseType = "Phishing", + Title = $"Suspicious URL: {sanitizedUrl}", + Description = string.IsNullOrWhiteSpace(request.Details) + ? $"Reported URL: {sanitizedUrl}" + : $"Reported URL: {sanitizedUrl}\n\nDetails: {SanitizeDescription(request.Details)}", + Source = "umbraco-web" }; var response = await SubmitToPhishLabsAsync(apiRequest, correlationId, cancellationToken); if (response.Success) { - _logger.LogInformation("PhishLabs incident submitted successfully. CorrelationId: {CorrelationId}, IncidentId: {IncidentId}", - correlationId, response.IncidentId); + _logger.LogInformation("PhishLabs case created successfully. CorrelationId: {CorrelationId}, CaseId: {CaseId}", + correlationId, response.CaseId); return new PhishLabsIncidentResponse { diff --git a/src/UmbracoWeb/UmbracoWeb/appsettings.json b/src/UmbracoWeb/UmbracoWeb/appsettings.json index f6c6f5f..75bf1da 100644 --- a/src/UmbracoWeb/UmbracoWeb/appsettings.json +++ b/src/UmbracoWeb/UmbracoWeb/appsettings.json @@ -43,9 +43,9 @@ "umbracoDbDSN_ProviderName": "Microsoft.Data.SqlClient" }, "PhishLabs": { - "ApiBaseUrl": "#{PHISHLABS_API_BASE_URL}#", + "ApiBaseUrl": "https://caseapi.phishlabs.com", "ApiKey": "#{PHISHLABS_API_KEY}#", - "ServicePath": "#{PHISHLABS_SERVICE_PATH}#", + "ServicePath": "/v1/create", "TimeoutSeconds": 30, "MaxRetries": 3, "RateLimitPerMinute": 10