add qhelp file

This commit is contained in:
thiggy1342
2022-06-24 02:19:06 +00:00
committed by GitHub
parent cf36333082
commit ca074e2275
2 changed files with 32 additions and 2 deletions

View File

@@ -0,0 +1,28 @@
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>
Directly checking request parameters without following a strong params
pattern can lead to unintentional avenues for injection attacks.
</p>
</overview>
<recommendation>
<p>
Instead of manually checking parameters from the `param` object, it is
recommended that you follow the strong parameters pattern established in
Rails: https://api.rubyonrails.org/classes/ActionController/StrongParameters.html
</p>
<p>
In the strong parameters pattern, you are able to specify required and allowed
parameters for each action called by your controller methods. This acts as an
additional layer of data validation before being passed along to other areas
of your application, such as the model.
</p>
</recommendation>
<references>
</references>
</qhelp>

View File

@@ -4,9 +4,10 @@
* @kind path-problem
* @problem.severity error
* @security-severity 5.0
* @precision low
* @precision medium
* @id rb/weak-params
* @tags security
* external/cwe/cwe-223
*/
import ruby
@@ -64,12 +65,13 @@ class ParamsReference extends ElementReference {
}
/**
* returns either Model or ViewModel classes with a base class of `ViewModel` or includes `ActionModel::Model`,
* returns either Model or ViewModel classes with a base class of `ViewModel`, `ApplicationRecord` or includes `ActionModel::Model`,
* which are required to support the strong parameters pattern
*/
class ModelClass extends ModuleBase {
ModelClass() {
this.getModule().getSuperClass+().toString() = "ViewModel" or
this.getModule().getSuperClass+().toString() = "ApplicationRecord" or
this.getModule().getSuperClass+().getAnIncludedModule().toString() = "ActionModel::Model"
}
}