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
4 changes: 2 additions & 2 deletions docs/PhishLabsIncidentReporter.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/UmbracoWeb/UmbracoWeb.Tests/UmbracoWeb.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnit.Analyzers" Version="4.4.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.4" />
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.4" />
<PackageReference Include="Moq" Version="4.20.70" />
</ItemGroup>

Expand Down
8 changes: 4 additions & 4 deletions src/UmbracoWeb/UmbracoWeb.Tests/UnitTest1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions src/UmbracoWeb/UmbracoWeb/Models/PhishLabsModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,23 @@ public class PhishLabsIncidentResponse
}

/// <summary>
/// Internal model for PhishLabs API request
/// Internal model for PhishLabs Case Creation API request
/// </summary>
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;
}

/// <summary>
/// Internal model for PhishLabs API response
/// Internal model for PhishLabs Case Creation API response
/// </summary>
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; }
}
17 changes: 10 additions & 7 deletions src/UmbracoWeb/UmbracoWeb/Services/PhishLabsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace UmbracoWeb.Services;

/// <summary>
/// Service for integrating with PhishLabs incident reporting API
/// Service for integrating with PhishLabs Case Creation API
/// </summary>
public class PhishLabsService : IPhishLabsService
{
Expand Down Expand Up @@ -52,20 +52,23 @@ public async Task<PhishLabsIncidentResponse> 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
{
Expand Down
4 changes: 2 additions & 2 deletions src/UmbracoWeb/UmbracoWeb/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down