Permalink
Cannot retrieve contributors at this time
30 lines (28 sloc)
725 Bytes
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/node_modules/eslint-plugin-github/lib/rules/authenticity-token.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
meta: { | |
type: 'problem', | |
docs: { | |
description: 'disallow usage of CSRF tokens in JavaScript', | |
url: require('../url')(module), | |
}, | |
schema: [], | |
}, | |
create(context) { | |
function checkAuthenticityTokenUsage(node, str) { | |
if (str.includes('authenticity_token')) { | |
context.report({ | |
node, | |
message: | |
'Form CSRF tokens (authenticity tokens) should not be created in JavaScript and their values should not be used directly for XHR requests.', | |
}) | |
} | |
} | |
return { | |
Literal(node) { | |
if (typeof node.value === 'string') { | |
checkAuthenticityTokenUsage(node, node.value) | |
} | |
}, | |
} | |
}, | |
} |