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

Add rule to check for HTTP headers that are not needed for non-HTML resources #91

Closed
wants to merge 1 commit into from
Closed

Add rule to check for HTTP headers that are not needed for non-HTML resources #91

wants to merge 1 commit into from

Conversation

alrra
Copy link
Contributor

@alrra alrra commented Apr 10, 2017

No description provided.

@alrra alrra requested a review from molant April 10, 2017 15:10
create(context: RuleContext): IRule {

const disallowedHeadersForNonHTMLResources = [
'content-security-policy',
Copy link
Member

Choose a reason for hiding this comment

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

Could there be other headers that we don't want for non html resources? Should we allow a configuration for this rule to allow ignoring some of those? Something similar to what you did for the other headers rule. Even if we don't agree, I think we should allow users to modify the headers to check or ignore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could there be other headers that we don't want for non html resources?

That may be, and if not, there will probably be new ones in the future.

Should we allow a configuration for this rule to allow ignoring some of those?

As opposed to the other rule, my thinking was that this one is very specific, either you want to use it or not. Also, new additions should be discussed and added in this project so that more people can benefit.

Even if we don't agree, I think we should allow users to modify the headers to check or ignore.

Given it a second thought today, maybe you're right. One case in particular where I can see a need to configure this is when someone wants to progressively work on removing the headers, but cannot do it all at once (e.g.: can only remove the ones set at the application level and not the server level).

Copy link
Contributor Author

@alrra alrra Apr 11, 2017

Choose a reason for hiding this comment

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

allow users to modify the headers to check or ignore

Done.


Note: I also refactored some of the code.

export const getRuleName = (dirname: string) => {
return path.basename(dirname);
};

export const mergeIgnoreIncludeArrays = (originalArray: Array<string> = [], ignoreArray: Array<string> = [], includeArray: Array<string> = []) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@molant Didn't have much inspiration today, so feel free to suggest other names for the new function from this file.

@alrra alrra closed this in c55bdfb Apr 12, 2017
@alrra alrra deleted the no-html-only-headers branch April 12, 2017 13:47
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.

2 participants