Skip to content

Commit e4d1e23

Browse files
Merge branch 'dev' into snyk-upgrade-226ddc85a5cfe7b7cb05070b8304f980
2 parents 7573d59 + 4cdb159 commit e4d1e23

16 files changed

Lines changed: 191 additions & 73 deletions

File tree

.github/workflows/pr-title-check.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ jobs:
3030
} else {
3131
core.setFailed('Cannot determine PR title for validation.')
3232
}
33-
const prTitleExpectedPattern = /(^LNK-\d+:\s)|(^TECH_DEBT:\s)|(^DOCS:\s)/g
34-
const prTitleMismatchError = 'Invalid PR title "' + prTitle + '"! Must begin with LNK-nnnn:<space> or TECH_DEBT:<space> or DOCS:<space>, e.g. LNK-1234: My PR title, or TECH_DEBT: My PR title or DOCS: My PR title'
33+
const prTitleExpectedPattern = /(^LNK-\d+:\s)|(^TECH_DEBT:\s)|(^DOCS:\s)|(^SNYK:\s)/g
34+
const prTitleMismatchError = 'Invalid PR title "' + prTitle + '"! Must begin with LNK-nnnn:<space> or TECH_DEBT:<space> or DOCS:<space> or SNYK:<space>, e.g. LNK-1234: My PR title, or TECH_DEBT: My PR title or DOCS: My PR title or [Snyk] My PR title'
3535
if (!prTitleExpectedPattern.test(prTitle)) {
3636
// Fail the workflow
3737
console.log(prTitleMismatchError)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
title: "SNYK: {{ snyk_pull_request_type }} for {{ package_name }}"
2+
description: |
3+
{{ #is_upgrade_pr }}
4+
This PR has been opened by Snyk to make sure our repositories are kept up-to-date.
5+
It updates **{{ package_name }}** from version {{ package_from }} to version {{ package_to }}.
6+
Review relevant docs for possible breaking changes.
7+
{{ /is_upgrade_pr }}
8+
9+
{{ #is_fix_pr }}
10+
This PR applies a fix for a vulnerability in **{{ package_name }}**.
11+
{{ /is_fix_pr }}
12+
13+
**Issues Fixed:** {{ issue_count }}

DotNet/Admin.BFF/Application/Commands/Integration/KafkaConsumerService.cs

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,30 +41,21 @@ public void StartConsumer(string groupId, List<string> topics, string reportTrac
4141
string traceId = string.Empty;
4242
string errorMessage = null;
4343

44-
if (consumeResult.Message.Headers.TryGetLastBytes("X-Correlation-Id",
45-
out var correlationHeader))
44+
if (consumeResult.Message.Headers.TryGetLastBytes("X-Correlation-Id", out var correlationHeader))
4645
{
4746
correlationId = System.Text.Encoding.UTF8.GetString(correlationHeader);
4847

4948
// read the exceptions
50-
if (consumeResult.Message.Headers.TryGetLastBytes("X-Exception-Message",
51-
out var exceptionMessage))
52-
{
53-
errorMessage = System.Text.Encoding.UTF8.GetString(exceptionMessage);
54-
}
55-
56-
else if (consumeResult.Message.Headers.TryGetLastBytes("X-Retry-Exception-Message",
57-
out var retryExceptionMessage))
58-
{
59-
errorMessage = System.Text.Encoding.UTF8.GetString(retryExceptionMessage);
60-
}
61-
62-
else if (consumeResult.Message.Headers.TryGetLastBytes("kafka_exception-message",
63-
out var kafkaErrorBytes))
49+
50+
if (TryReadHeader(consumeResult.Message.Headers, out var errorBytes,
51+
"X-Exception-Message",
52+
"X-Retry-Exception-Message",
53+
"kafka_exception-message",
54+
"kafka_dlt-exception-message"))
6455
{
65-
errorMessage = System.Text.Encoding.UTF8.GetString(kafkaErrorBytes);
56+
errorMessage = System.Text.Encoding.UTF8.GetString(errorBytes);
6657
}
67-
58+
6859
// Extract traceId from traceparent header
6960
if (consumeResult.Message.Headers.TryGetLastBytes("traceparent", out var traceParentBytes))
7061
{
@@ -155,6 +146,23 @@ public void StartConsumer(string groupId, List<string> topics, string reportTrac
155146
}
156147
}
157148

149+
private static bool TryReadHeader(
150+
Headers headers,
151+
out byte[] value,
152+
params string[] keys)
153+
{
154+
foreach (var key in keys)
155+
{
156+
if (headers.TryGetLastBytes(key, out value))
157+
{
158+
return true;
159+
}
160+
}
161+
162+
value = null!;
163+
return false;
164+
}
165+
158166
private bool checkReportTrackingId(string input, string reportTrackingId)
159167
{
160168
if (string.IsNullOrEmpty(input)) return false;

DotNet/Report/Domain/MongoIndexCreationService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class MongoIndexCreationService : BackgroundService
77
{
88
private readonly ILogger<MongoIndexCreationService> _logger;
99
private readonly IServiceScopeFactory _serviceScopeFactory;
10-
public MongoIndexCreationService(ILogger<MongoIndexCreationService> logger, IServiceScopeFactory factory)
10+
public MongoIndexCreationService(ILogger<MongoIndexCreationService> logger, IServiceScopeFactory factory)
1111
{
1212
_logger = logger;
1313
_serviceScopeFactory = factory;

DotNet/Report/Domain/Queries/SubmissionEntryQueries.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,11 @@ public async Task<bool> PatientAllReadyForValidation(
246246
string patientId,
247247
CancellationToken cancellationToken = default)
248248
{
249-
return await (from entry in _context.PatientSubmissionEntries
250-
where entry.ReportScheduleId == reportScheduleId && entry.FacilityId == facilityId && entry.PatientId == patientId
251-
select entry.Status).AllAsync(s => s == PatientSubmissionStatus.ReadyForValidation || s == PatientSubmissionStatus.NotReportable);
249+
List<PatientSubmissionStatus> statuses = await (from entry in _context.PatientSubmissionEntries
250+
where entry.ReportScheduleId == reportScheduleId && entry.FacilityId == facilityId && entry.PatientId == patientId
251+
select entry.Status).ToListAsync(cancellationToken);
252+
return statuses.All(s => s == PatientSubmissionStatus.ReadyForValidation || s == PatientSubmissionStatus.NotReportable) &&
253+
statuses.Any(s => s == PatientSubmissionStatus.ReadyForValidation);
252254
}
253255

254256
public async Task<PagedConfigModel<ResourceSummary>> GetResourceSummary(string facilityId, string reportScheduleId, ResourceType? resourceType, int pageSize, int pageNumber,

DotNet/Report/KafkaProducers/ReportManifestProducer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ private OperationOutcome CreateOperationOutcome(List<PatientSubmissionEntry> fai
235235
// Assuming PatientSubmissionEntry has a ValidationMessage property; adjust as per actual model
236236
operationOutcome.Issue.Add(new OperationOutcome.IssueComponent
237237
{
238-
Severity = OperationOutcome.IssueSeverity.Fatal,
238+
Severity = OperationOutcome.IssueSeverity.Error,
239239
Code = OperationOutcome.IssueType.Invalid,
240240
Diagnostics = $"Validation failed for patient {entry.PatientId}"
241241
});

DotNet/Report/Listeners/ValidationCompleteListener.cs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using System.Text;
2020
using LantanaGroup.Link.Shared.Application.Services.Security;
2121
using Task = System.Threading.Tasks.Task;
22+
using Hl7.Fhir.Support;
2223

2324
namespace LantanaGroup.Link.Report.Listeners
2425
{
@@ -190,18 +191,12 @@ public async Task ProcessMessageAsync(ConsumeResult<string, ValidationCompleteVa
190191
throw new DeadLetterException($"No Patient Submission Entries were found for schedule ID {schedule.Id}, patient ID {value.PatientId}, in status {PatientSubmissionStatus.ValidationRequested}");
191192
}
192193

194+
var operationOutcome = GetOperationOutcome();
195+
193196
foreach (var entry in submissionEntries)
194197
{
195198
if (!value.IsValid)
196199
{
197-
var operationOutcome = new OperationOutcome();
198-
var issue = new OperationOutcome.IssueComponent
199-
{
200-
Severity = OperationOutcome.IssueSeverity.Fatal,
201-
Code = OperationOutcome.IssueType.Invalid,
202-
Diagnostics = "Patient has failed Validation"
203-
};
204-
operationOutcome.Issue = new List<OperationOutcome.IssueComponent> { issue };
205200
await submissionEntryManager.AddResourceAsync(entry, operationOutcome, ResourceCategoryType.Patient, cancellationToken);
206201
}
207202

@@ -269,6 +264,21 @@ await submissionEntryManager.UpdateAsync(new PatientSubmissionEntryUpdateModel
269264
await _reportManifestProducer.Produce(schedule, correlationIdStr);
270265
}
271266

267+
private static OperationOutcome GetOperationOutcome()
268+
{
269+
OperationOutcome operationOutcome = new()
270+
{
271+
Id = Guid.NewGuid().ToString()
272+
};
273+
operationOutcome.AddIssue(new OperationOutcome.IssueComponent
274+
{
275+
Severity = OperationOutcome.IssueSeverity.Error,
276+
Code = OperationOutcome.IssueType.Invalid,
277+
Diagnostics = "Patient has failed Validation"
278+
});
279+
return operationOutcome;
280+
}
281+
272282
private static string GetFacilityIdFromHeader(Headers headers)
273283
{
274284
string facilityId = string.Empty;

Java/measureeval/src/main/java/com/lantanagroup/link/measureeval/configs/SecurityConfig.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import com.lantanagroup.link.shared.auth.JwtAuthenticationEntryPoint;
44
import com.lantanagroup.link.shared.auth.JwtAuthenticationFilter;
55
import com.lantanagroup.link.shared.security.SecurityHelper;
6+
import org.slf4j.Logger;
7+
import org.slf4j.LoggerFactory;
68
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
79
import org.springframework.context.annotation.Bean;
810
import org.springframework.context.annotation.ComponentScan;
@@ -39,10 +41,20 @@ public SecurityFilterChain securityFilterChain (HttpSecurity http) throws Except
3941
}
4042
}
4143

44+
/**
45+
* This class is necessary to support @PreAuthorize and @PostAuthorize when
46+
* anonymous mode is enabled. The condition causes the Dummy class to get registered
47+
* and for the @EnableMethodSecurity to be applied, which affects all classes, enabling @PreAuthorize/@PostAuthorize
48+
*/
4249
@ConditionalOnProperty(prefix = "authentication",
43-
name = "enableAnonymousAccess",
50+
name = "anonymous",
4451
havingValue = "false")
4552
@EnableMethodSecurity(prePostEnabled = true)
4653
static class Dummy {
54+
private static final Logger logger = LoggerFactory.getLogger(Dummy.class);
55+
56+
public Dummy() {
57+
logger.info("Anonymous authentication disabled - @EnableMethodSecurity is being applied (authentication.anonymous=false)");
58+
}
4759
}
4860
}

Java/measureeval/src/main/java/com/lantanagroup/link/measureeval/controllers/MeasureDefinitionController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
@RestController
3333
@RequestMapping("/api/measureeval/measure-definition")
34-
@PreAuthorize("hasRole('LinkUser')")
34+
@PreAuthorize("hasAnyRole('LinkUser', 'LinkAdministrator')")
3535
public class MeasureDefinitionController {
3636

3737
private final Logger _logger = LoggerFactory.getLogger(MeasureDefinitionController.class);

Java/measureeval/src/main/java/com/lantanagroup/link/measureeval/controllers/PatientController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
@RestController
1515
@RequestMapping("/api/measureeval/patient")
16-
@PreAuthorize("hasRole('LinkUser')")
16+
@PreAuthorize("hasAnyRole('LinkUser', 'LinkAdministrator')")
1717
public class PatientController {
1818
private final PatientReportingEvaluationStatusRepository patientReportingEvaluationStatusRepository;
1919
private final PatientStatusBundler patientStatusBundler;

0 commit comments

Comments
 (0)