Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes some issues reported by linter. #303

Merged
merged 1 commit into from
Mar 31, 2022

Conversation

armfazh
Copy link
Member

@armfazh armfazh commented Feb 15, 2022

No description provided.

@armfazh armfazh self-assigned this Feb 15, 2022
@@ -242,21 +243,21 @@ export class CloudflareProvider implements Provider {
// header according to https://xhr.spec.whatwg.org/#dom-xmlhttprequest-setrequestheader
// So we need to extract the token from the Referer header and send it in the query
// param __cf_chl_f_tk instead. (Note that this token is not a Privacy Pass token.
let token: string | null = null;
let atoken: string | null = null;
Copy link
Member

Choose a reason for hiding this comment

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

What does this mean? Is it a lint error? I cannot find it from npm run lint?

Copy link
Member

Choose a reason for hiding this comment

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

I think token (without s) already means a token.

Copy link
Member Author

Choose a reason for hiding this comment

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

Linter reports security/detect-possible-timing-attacks when detects a variable named token or password.

https://github.com/gkouziik/eslint-plugin-security-node/blob/master/lib/rules/detect-possible-timing-attacks.js

@@ -335,14 +340,14 @@ export class CloudflareProvider implements Provider {

// Get one token.
const tokens = this.getStoredTokens();
const token = tokens.shift();
const oneToken = tokens.shift();
Copy link
Member

Choose a reason for hiding this comment

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

I think token (without s) already means one token.

Copy link
Member Author

Choose a reason for hiding this comment

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

the issue is that the linter looks for variables named token or password and warns about it. The fix proposed is to rename the variable.

if (details.requestBody.formData[key].length == 1) {
const [value] = details.requestBody.formData[key];
flattenFormData[key] = value;
if (details.requestBody.formData[key as string].length == 1) {
Copy link
Member

@ppopth ppopth Feb 15, 2022

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I think defining a function checking for the key of constructor, __proto__, and prototype should be fine.

Copy link
Member Author

Choose a reason for hiding this comment

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

According to the reference:

How do I fix it?
The most direct fix here is going to be to avoid the use of user input in property name fields. This isn't reasonable in all circumstances, however, and there should be a way to safely use core language features.

so, we need to refactor code to avoid property name fields. Open to suggestions for this change.

@armfazh armfazh merged commit ee02cc8 into privacypass:master Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants