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

False positive detect-non-literal-fs-filename on _.exists #26

Closed
fluxsauce opened this issue Dec 20, 2017 · 12 comments
Closed

False positive detect-non-literal-fs-filename on _.exists #26

fluxsauce opened this issue Dec 20, 2017 · 12 comments

Comments

@fluxsauce
Copy link

Using lodash 4.17.4 and lodash-exists 1.0.3.

const _ = require('lodash');
require('lodash-exists');

...

if (_.exists(memberId)) {
  this.memberId = memberId;
}

Found fs.exists with non literal argument at index 0 security/detect-non-literal-fs-filename

@evilpacket
Copy link
Contributor

yup. This needs to be re-written to actually see if fs was used, track it's assignment and make sure that method calls are on those objects. It's not impossible, we do a hacky version of it in the child_process.exec check.

@ozsay
Copy link

ozsay commented Apr 2, 2018

@evilpacket any word on a possible fix?

@MeenaAlfons
Copy link

More false positives for security/detect-non-literal-fs-filename. Example:

screen shot 2019-02-03 at 13 21 14

Error:

Found fs.open with non literal argument at index 0
eslint(security/detect-non-literal-fs-filename)

@feenst
Copy link

feenst commented Oct 5, 2019

Also fails for RegExp.prototype.exec():

image

Error:

Found fs.link with non-literal argument at index 0
eslint(security/detect-non-literal-fs-filename)

@joshuagoran
Copy link

I'm seeing similar false positives. any chance these might be resolved? for me, I'm seeing it with TestCafe assertions.
Screen Shot 2020-03-23 at 11 04 41 AM

@ZuBB
Copy link

ZuBB commented Apr 13, 2020

same for window.open()

@Luxcium
Copy link

Luxcium commented May 29, 2020

same for me with exists in

// [...]
export async function some(key: string) {
  const tedis = new Tedis();
  ifThen(tedis.exists(key))
    .then(i=>i)
    .catch(error => console.error('error message:', error.message));
}
// [...]

@jbaris
Copy link

jbaris commented Jan 8, 2021

same for $uibModal.open()

@cata-on
Copy link

cata-on commented Sep 30, 2021

Same for .watch (with TS).
E.g.

const obj = {
  watch: (a: any): void => {
    console.log(a);
  },
};
obj.watch(obj);

@ota-meshi
Copy link
Member

I believe this issue has been fixed in the latest version.
https://github.com/eslint-community/eslint-plugin-security/releases/tag/v1.6.0
It was fixed by PR #92.

@nzakas
Copy link
Contributor

nzakas commented Jan 12, 2023

Agreed.

@nzakas nzakas closed this as completed Jan 12, 2023
@fluxsauce
Copy link
Author

Brilliant, thank you!

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

No branches or pull requests

13 participants