JS: Add test case for graph ql variableValues injection

This commit is contained in:
Napalys Klicius
2025-09-17 12:21:21 +02:00
parent 6d461d6b50
commit 6c18b4de40

View File

@@ -33,4 +33,24 @@ app.post('/graphql', async (req, res) => {
variableValues: variables
});
res.json(result);
const root1 = {
greet: ({ name, title }) => {
return eval(name + title).toString(); // $ MISSING: Alert[js/code-injection]
}
};
graphql({
schema: buildSchema(`
type Query {
greet(name: String!, title: String): String
}
`),
source: `
query GreetUser($name: String!, $title: String) {
greet(name: $name, title: $title)
}
`,
rootValue: root1,
variableValues: variables
});
});