-
-
Notifications
You must be signed in to change notification settings - Fork 78
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 from .findOne()
using Sequelize
#114
Comments
Thanks for the report and the PR. This should be merged now. |
I've been into a rabbit hole since GitLab's pipeline started failing last week at work, it seems this is the cause. We are using TypeORM (which also exposes a @ajinabraham I really don't support jumping into a issue and demanding stuff from a maintainer but is it possible to look into this? I'm not familiar with the library (it was already in place when I started working on the project) but I'd gladly take a look and see if I can implement a similar fix so people using TypeORM and njsscan don't run into this. Thanks in advance. |
If you can share a code snippet with imports and such triggering this false positive, I can add it to the ruleset. |
The following code should trigger the false positive, I tested it using the rule in Semgrep and it works. import { Repository } from 'typeorm';
export class UserService {
constructor(
private userRepository: Repository<User>,
) {}
public async findUser(userIn: UserIn): Promise<User> {
return this.userRepository.findOne({
where: {
id: userIn.id
},
});
}
} Again, I'm not familiar with the way rules are defined but looking at the fix for Sequelize I guess something along the lines of the following should work, but I'm not sure:
|
I am getting the following vulnerability flagged:
in the following snippet of my code:
For reference, here is role.js
As seen from my code, it uses the
.findOne()
function fromsequelize
(docs).I believe this flag is a false-positive, since:
Looking at the njsscan source code, this issue was flagged out by
njsscan/rules/semantic_grep/database/nosql_find_injection.yaml
(link), which does a simple pattern matching for.findOne()
and its variants.Perhaps an extra pattern check should be added for code using/importing
sequelize
, to prevent false positives arising from this rule?The text was updated successfully, but these errors were encountered: