Skip to content

Commit fe205c7

Browse files
authored
Merge pull request #12 from markcoleman/copilot/ensure-case-creation-api-use
2 parents 650efec + 598619e commit fe205c7

File tree

6 files changed

+26
-23
lines changed

6 files changed

+26
-23
lines changed

docs/PhishLabsIncidentReporter.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ Add the PhishLabs settings to your `appsettings.json`:
2828
```json
2929
{
3030
"PhishLabs": {
31-
"ApiBaseUrl": "https://api.phishlabs.com",
31+
"ApiBaseUrl": "https://caseapi.phishlabs.com",
3232
"ApiKey": "your-api-key-here",
33-
"ServicePath": "/incidents/your-service",
33+
"ServicePath": "/v1/create",
3434
"TimeoutSeconds": 30,
3535
"MaxRetries": 3,
3636
"RateLimitPerMinute": 10

src/UmbracoWeb/UmbracoWeb.Tests/UmbracoWeb.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
<PackageReference Include="NUnit" Version="4.2.2" />
1515
<PackageReference Include="NUnit.Analyzers" Version="4.4.0" />
1616
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
17-
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.0" />
18-
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.0" />
17+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.4" />
18+
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.4" />
1919
<PackageReference Include="Moq" Version="4.20.70" />
2020
</ItemGroup>
2121

src/UmbracoWeb/UmbracoWeb.Tests/UnitTest1.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ public void SetUp()
2828

2929
_settings = new PhishLabsSettings
3030
{
31-
ApiBaseUrl = "https://api.phishlabs.com",
31+
ApiBaseUrl = "https://caseapi.phishlabs.com",
3232
ApiKey = "test-key",
33-
ServicePath = "/incidents/test",
33+
ServicePath = "/v1/create",
3434
TimeoutSeconds = 30,
3535
MaxRetries = 3,
3636
RateLimitPerMinute = 10
@@ -61,8 +61,8 @@ public async Task SubmitIncidentAsync_WithValidRequest_ReturnsSuccessResponse()
6161
var apiResponse = new
6262
{
6363
success = true,
64-
incidentId = "incident-456",
65-
message = "Incident created successfully"
64+
caseId = "case-456",
65+
message = "Case created successfully"
6666
};
6767

6868
var responseContent = JsonSerializer.Serialize(apiResponse, new JsonSerializerOptions

src/UmbracoWeb/UmbracoWeb/Models/PhishLabsModels.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,23 @@ public class PhishLabsIncidentResponse
4949
}
5050

5151
/// <summary>
52-
/// Internal model for PhishLabs API request
52+
/// Internal model for PhishLabs Case Creation API request
5353
/// </summary>
5454
internal class PhishLabsApiRequest
5555
{
56-
public string Url { get; set; } = string.Empty;
57-
public string? Description { get; set; }
56+
public string CaseType { get; set; } = "Phishing";
57+
public string Title { get; set; } = string.Empty;
58+
public string Description { get; set; } = string.Empty;
5859
public string Source { get; set; } = "umbraco-web";
59-
public DateTime Timestamp { get; set; } = DateTime.UtcNow;
6060
}
6161

6262
/// <summary>
63-
/// Internal model for PhishLabs API response
63+
/// Internal model for PhishLabs Case Creation API response
6464
/// </summary>
6565
internal class PhishLabsApiResponse
6666
{
6767
public bool Success { get; set; }
68-
public string? IncidentId { get; set; }
68+
public string? CaseId { get; set; }
6969
public string? Message { get; set; }
7070
public string? Error { get; set; }
7171
}

src/UmbracoWeb/UmbracoWeb/Services/PhishLabsService.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace UmbracoWeb.Services;
77

88
/// <summary>
9-
/// Service for integrating with PhishLabs incident reporting API
9+
/// Service for integrating with PhishLabs Case Creation API
1010
/// </summary>
1111
public class PhishLabsService : IPhishLabsService
1212
{
@@ -52,20 +52,23 @@ public async Task<PhishLabsIncidentResponse> SubmitIncidentAsync(
5252

5353
try
5454
{
55+
var sanitizedUrl = SanitizeUrl(request.Url);
5556
var apiRequest = new PhishLabsApiRequest
5657
{
57-
Url = SanitizeUrl(request.Url),
58-
Description = SanitizeDescription(request.Details),
59-
Source = "umbraco-web",
60-
Timestamp = DateTime.UtcNow
58+
CaseType = "Phishing",
59+
Title = $"Suspicious URL: {sanitizedUrl}",
60+
Description = string.IsNullOrWhiteSpace(request.Details)
61+
? $"Reported URL: {sanitizedUrl}"
62+
: $"Reported URL: {sanitizedUrl}\n\nDetails: {SanitizeDescription(request.Details)}",
63+
Source = "umbraco-web"
6164
};
6265

6366
var response = await SubmitToPhishLabsAsync(apiRequest, correlationId, cancellationToken);
6467

6568
if (response.Success)
6669
{
67-
_logger.LogInformation("PhishLabs incident submitted successfully. CorrelationId: {CorrelationId}, IncidentId: {IncidentId}",
68-
correlationId, response.IncidentId);
70+
_logger.LogInformation("PhishLabs case created successfully. CorrelationId: {CorrelationId}, CaseId: {CaseId}",
71+
correlationId, response.CaseId);
6972

7073
return new PhishLabsIncidentResponse
7174
{

src/UmbracoWeb/UmbracoWeb/appsettings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@
4343
"umbracoDbDSN_ProviderName": "Microsoft.Data.SqlClient"
4444
},
4545
"PhishLabs": {
46-
"ApiBaseUrl": "#{PHISHLABS_API_BASE_URL}#",
46+
"ApiBaseUrl": "https://caseapi.phishlabs.com",
4747
"ApiKey": "#{PHISHLABS_API_KEY}#",
48-
"ServicePath": "#{PHISHLABS_SERVICE_PATH}#",
48+
"ServicePath": "/v1/create",
4949
"TimeoutSeconds": 30,
5050
"MaxRetries": 3,
5151
"RateLimitPerMinute": 10

0 commit comments

Comments
 (0)