Repository navigation
Legacy Defensive Checks Role Supplier JSON
The legacy hardening work exposed three boundary cases where permissive matching or broad fallback behavior can hide defects. Test the negative cases alongside the intended success path.
JwtRoleChecker.hasRole accepts a concrete role and abstract roles that begin
with the exact role plus an underscore. hasConcreteRole checks only the exact
role, while hasAbstractRole checks the exact prefix and client identifier.
For a role such as PLANNER, cover the concrete PLANNER value and an intended
value such as PLANNER_12345. Also reject unrelated authorities such as
SUPER_PLANNER_12345. A substring check would accept that unintended
authority.
Relevant code and tests:
JwtRoleChecker.javaJwtRoleCheckerIntegrationTest.javaJwtRoleAuthorizationManagerFactoryTest.java
Spring authorization events expose authentication through a supplier. Read it once into a local variable, then use that same value for classification and logging. Repeated calls can observe different results from a deferred or stateful supplier, and they make exactly-once behavior harder to test.
SecurityEventLoggingListener.onAuthorizationDenied now resolves the supplier
once before distinguishing an absent or anonymous authentication (401) from an
authenticated denial (403).
SecurityEventLoggingListenerTest.authorizationDenialReadsAuthenticationSupplierOnce
verifies the call count and classification.
Relevant code and test:
SecurityEventLoggingListener.javaSecurityEventLoggingListenerTest.java
When malformed secondary-mark JSON should produce an empty list, catch Jackson's
JacksonException around deserialization. Do not catch every Exception: that
can turn unrelated programming errors or unexpected runtime failures into
apparently valid empty results.
The mapper tests cover null, blank, valid, empty-array, and malformed JSON.
Keeping the catch limited to JacksonException preserves the fallback for
invalid input without swallowing unrelated runtime defects.
Relevant code and test:
ReportingUnitSearchExpandedMapper.javaReportingUnitSearchExpandedMapperTest.java
- Does a role matcher enforce the separator and complete identifier boundary?
- Does code resolve a deferred supplier once before branching on its value?
- Does a fallback catch only the expected failure type?
- Do tests prove the accepted path and a nearby rejected or propagated failure?
This wiki documents NR Waste Plus for users and developers. Verify security and deployment guidance against the current application configuration before applying it elsewhere.
- Report an issue or ask a question in the GitHub repository.
- Follow the Contributing Guidelines to propose an update.
- Read the Code of Conduct.
Collection indexes support human browsing and machine retrieval. Keep both current when adding or moving wiki pages.
NR Waste Plus Wiki | GitHub Repository