-
Notifications
You must be signed in to change notification settings - Fork 22
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
Notes about eslint-plugin-security
#670
Comments
I don't mind having to write warning suppressions with justification. The main thing is getting the number of down to a level where we're not in a "boy who cried wolf situation" during development and PR review In "normal" application code, we should by and large be able to use The main areas where
Overall, this becomes more relevant when we introduce the public marketplace. In that world, we can also "flag" certain kinds of bricks as higher risk due to their potential behavior |
I've seen this justification a few times in the code: pixiebrix-extension/src/background/auth.ts Lines 71 to 73 in 86fd023
If that's correct, what do you think about creating a export function safeGet<
TKey extends string,
TObject extends Record<TKey, unknown>
>(object: TObject, key: TKey): TObject[TKey] {
if (Object.prototype.hasOwnProperty.call(object, key)) {
// eslint-disable-next-line security/detect-object-injection -- Safe!
return object[key];
}
throw new Error(`Key ${key} is not a direct property of object`);
} (types are ok but are likely improvable) This would let us change this: // Make sure we don't install the content script multiple times
// eslint-disable-next-line security/detect-object-injection -- using PIXIEBRIX_SYMBOL
const existing: string = window[PIXIEBRIX_SYMBOL]; to import {safeGet} from "@/utils";
const existing: string = safeGet(window, PIXIEBRIX_SYMBOL); |
Closing as my last attempt at this was not merged: |
(This is a non-issue, just for discussion purposes)
security/detect-object-injection
has a lot of false positives. Could a solution be in this long SO answer? https://stackoverflow.com/q/57960770Related (but no solution here)
The text was updated successfully, but these errors were encountered: