Skip to content

fix(audits): inconsistency between D6D5 and 6A70 - #147

Merged
enisdenjo merged 1 commit into
graphql:mainfrom
DoctorJohn:fix-inconsistent-assertions
Jun 6, 2025
Merged

fix(audits): inconsistency between D6D5 and 6A70#147
enisdenjo merged 1 commit into
graphql:mainfrom
DoctorJohn:fix-inconsistent-assertions

Conversation

@DoctorJohn

Copy link
Copy Markdown
Contributor

D6D5 and 6A70 essentially perform the same audit check. However, while 6A70 checks that the execution result has no errors, D6D5 does not. This PR updates D6D5 to also check that the execution result has no errors (i.e, make both audit functions do the same assertions).

Relevant code:

audit(
'D6D5',
'MAY allow URL-encoded JSON string {variables} parameter in GETs when accepting application/graphql-response+json',
async () => {
const url = new URL(await getUrl(opts.url));
url.searchParams.set(
'query',
'query Type($name: String!) { __type(name: $name) { name } }',
);
url.searchParams.set('variables', JSON.stringify({ name: 'sometype' }));
const res = await fetchFn(url.toString(), {
method: 'GET',
headers: {
accept: 'application/graphql-response+json',
},
});
ressert(res).status.toBe(200);
},
),
audit(
'6A70',
'MAY allow URL-encoded JSON string {variables} parameter in GETs when accepting application/json',
async () => {
const url = new URL(await getUrl(opts.url));
url.searchParams.set(
'query',
'query Type($name: String!) { __type(name: $name) { name } }',
);
url.searchParams.set('variables', JSON.stringify({ name: 'sometype' }));
const res = await fetchFn(url.toString(), {
method: 'GET',
headers: {
accept: 'application/json',
},
});
ressert(res).status.toBe(200);
await ressert(res).bodyAsExecutionResult.notToHaveProperty('errors');
},
),

The check that's only present in 6A70 but not in D6D5:

await ressert(res).bodyAsExecutionResult.notToHaveProperty('errors');

@enisdenjo

enisdenjo commented Jun 6, 2025

Copy link
Copy Markdown
Member

There is a fine detail here: application/json uses 200 almost always (true legacy servers truly always) and the only way to detect an error there is by looking at the errors entry - which is what the test checks; on the other hand, application/graphql-response+json will return a 400 in case of invalid parameters, not needing to check the errors entry.

But nevertheless, the extra assertion wont hurt!

@enisdenjo
enisdenjo merged commit eac6dc8 into graphql:main Jun 6, 2025
theguild-bot pushed a commit that referenced this pull request Aug 7, 2026
# [1.23.0](v1.22.4...v1.23.0) (2026-08-07)

### Bug Fixes

* add support for GraphQL v17 ([#156](#156)) ([ae03a11](ae03a11)), closes [#155](#155)
* **audits:** avoid false positives in 9ABE ([#148](#148)) ([5587c03](5587c03))
* **audits:** inconsistency between D6D5 and 6A70 ([#147](#147)) ([eac6dc8](eac6dc8))
* **audits:** incorrect status code range ([#145](#145)) ([08b4ed2](08b4ed2))

### Features

* **audit:** graphql-response+json parsing failure handling ([#149](#149)) ([81e6a07](81e6a07))
@theguild-bot

Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 1.23.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@theguild-bot theguild-bot added the released Has been released and published label Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Has been released and published

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants