Skip to content

Conversation

@abright25
Copy link

No description provided.

@abright25 abright25 changed the title Add broken access control test options feat(scan): add broken access control test options Jan 13, 2026
@abright25 abright25 added the Type: enhancement New feature or request. label Jan 13, 2026

This comment was marked as resolved.

abright25 and others added 3 commits January 14, 2026 19:22
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@abright25 abright25 self-assigned this Jan 14, 2026
@abright25 abright25 changed the title feat(scan): add broken access control test options feat(scan): add ability to run broken access control test with required options Jan 14, 2026
@abright25 abright25 marked this pull request as ready for review January 14, 2026 18:50
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the file name plural? It seems the main entry is not collection.

Copy link
Author

@abright25 abright25 Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will add more configurable tests in the future. BAC is not the only one test with options.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neither BrokenAccessControlTest nor BrokenAccessControlOptions are not the main entry in this file. The only entry is Test, not even Tests. So, the file should correspond to that.

mockedCi,
mockedConfiguration
)
reset<ApiClient | Configuration>(mockedApiClient, mockedConfiguration)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now the tests is gonna behave incorrectly, CI mock is not being reset.

mappedTests: string[],
testMetadata: Record<string, unknown>
) {
if (!test.options?.auth) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets TS enforce correctness instead of runtime checks

Comment on lines +141 to +142
typeof auth !== 'string' &&
(!Array.isArray(auth) || auth.length !== 2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

continue;
}

if (test.name === 'broken_access_control') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is technically redundant today, compiler knows the only single test with options

Comment on lines +86 to +103
if (!config.tests) {
return { ...config };
}

const { mappedTests, testMetadata } = this.mapTests(config.tests);
const { tests: originalTests, ...restConfig } = config;

if (Object.keys(testMetadata).length > 0) {
const result: Record<string, unknown> = {
...restConfig,
tests: mappedTests,
testMetadata
};

return result;
}

return { ...config };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intent is unclear from both the name and implementation. Rename the method to reflect its role and avoid imperative style.

Suggested change
if (!config.tests) {
return { ...config };
}
const { mappedTests, testMetadata } = this.mapTests(config.tests);
const { tests: originalTests, ...restConfig } = config;
if (Object.keys(testMetadata).length > 0) {
const result: Record<string, unknown> = {
...restConfig,
tests: mappedTests,
testMetadata
};
return result;
}
return { ...config };
const mapped = config.tests.map(test => this.mapTest(test));
const tests = mapped.map(t => t.name);
const testMetadata = mapped.reduce<TestMetadata | undefined>(
(acc, { metadata }) =>
metadata
? { ...acc, ...metadata }
: acc,
undefined
);
return {
...config,
tests,
...(testMetadata && { testMetadata }),
};

expect(result).toEqual({ id });
});

it('should throw error when broken_access_control test has no auth option', async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and tests below are no longer relevant due to https://github.com/NeuraLegion/sectester-js/pull/270/changes#r2692255661

}

if (seenTestConfigurations.has(testName) || simpleTests.has(testName)) {
throw new Error(`Duplicate test configuration found: ${testName}`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error messages should include CTA

Suggested change
throw new Error(`Duplicate test configuration found: ${testName}`);
throw new Error(`Please remove a duplicate for the ${testName} test`);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: enhancement New feature or request.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants