-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Extend aspnetcore controller definition #9406
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
Conversation
The linked documentation states
Isn't this a conjunction between the three paragraphs? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have added some comments and questions.
Also, it would be great, if it is possible to extend the unit test coverage.
csharp/ql/lib/semmle/code/csharp/frameworks/microsoft/AspNetCore.qll
Outdated
Show resolved
Hide resolved
csharp/ql/lib/semmle/code/csharp/frameworks/microsoft/AspNetCore.qll
Outdated
Show resolved
Hide resolved
That's the point. The controller can be any class suffixed with Controller and it is convenient, but not obligatory to be in the root folder. See the project attached. There are two endpoints |
Alright. I am not well versed in ASP.NET. |
Correct. |
|
@JarLob Can you point me to some documentation on convention based controllers? |
You mean the link in my first comment? https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/actions?view=aspnetcore-3.1 Current implementation probably covers 95% of use cases (99% with the PR). I'm not concerned about covering the last 1% if they are loaded dynamically etc. The question is if this commit introduces more FPs. Please see if cf561ed is sufficient. |
Looks reasonable to me. |
Could you please help me with the tests? I tried to find something similar and used |
I've ran Regarding the duplicate
and
The latter one has a lot more source files from the stubs folder, but I only found one |
I have added the tests. There are two issues though:
|
I have taken the liberty to force push some commits to the branch (hope that is ok). |
@JarLob : Are the pushed changes aligned with your thinking on the topic? |
Totally. Sorry for the late reply and thank you for fixing it for me! Tests are green. Is anything else needed to be done for it to be merged? Updating the branch? |
No problem - happy to help. 👍 The following needs to be done:
Let me know, if you need any assistance with the above. |
Done, but it is a moving target.
Added.
I don't have permissions to add reviewers. Could you please request the review from @tamasvajk ?
What is DCA and how to run it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but let's await the second review as well. 👍
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM apart from a minor issue in the change notes.
--- | ||
category: minorAnalysis | ||
--- | ||
* ASP.NET Core controller definition made more precise. The amount of introduced taint sources or eliminated false positives should be low though, since the most common pattern is to derive all user defined ASP.NET Core controllers from the standard Controller class, which is not affected. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a native speaker, but doesn't ASP.NET Core controller definition has been made more precise.
sound better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neither am I. I have definitely forgot to add was
at least. Fixed.
csharp/ql/lib/change-notes/2022-08-24-aps-net-core-controllers.md
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, let's wait for the DCA results before merging.
I must admit I forgot about this PR. Before merging, I would like to re-base the PR and just re-execute the unit tests. |
… Redirect methods to be considered sinks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
No manual changes required for rebasing.
Everything still looks good. |
AspNetCore is more flexible deciding what are controllers than AspNet - https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/actions?view=aspnetcore-3.1
The controller class class doesn't have to be derived from a specific parent, it is enough to suffix it or any parent class with Controller. Also [Controller] and [NonController] attributes should be taken into account.
This should add potentially missed taint sources.