Merge pull request #17240 from knewbury01/knewbury01/fix-helmetrequiredsetting-model

Update JS helmet model structure
This commit is contained in:
Asger F 2024-08-22 11:59:28 +02:00 коммит произвёл GitHub
Родитель bd69b96752 7dcdad066f
Коммит a1688f6a1a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
4 изменённых файлов: 44 добавлений и 25 удалений

Просмотреть файл

@ -1,6 +1,6 @@
extensions:
- addsTo:
pack: codeql/javascript-queries
pack: codeql/javascript-all
extensible: requiredHelmetSecuritySetting
data:
- ["frameguard"]

Просмотреть файл

@ -0,0 +1,41 @@
/**
* Provides classes for working with Helmet
*/
private import javascript
/**
* A write to a property of a route handler from the "helmet" module.
*/
class HelmetProperty extends DataFlow::Node instanceof DataFlow::PropWrite {
ExpressLibraries::HelmetRouteHandler helmet;
HelmetProperty() {
this = helmet.(DataFlow::CallNode).getAnArgument().getALocalSource().getAPropertyWrite()
}
/**
* Gets the route handler associated to this property.
*/
ExpressLibraries::HelmetRouteHandler getHelmet() { result = helmet }
/**
* Gets the boolean value of this property, if it may evaluate to a `Boolean`.
*/
predicate isFalse() { DataFlow::PropWrite.super.getRhs().mayHaveBooleanValue(false) }
/**
* Gets the name of the `HelmetProperty`.
*/
string getName() { result = DataFlow::PropWrite.super.getPropertyName() }
/**
* read from data extensions to allow enforcing custom settings
*/
predicate isImportantSecuritySetting() { requiredHelmetSecuritySetting(this.getName()) }
}
/**
* defaults are located in `javascript/ql/lib/semmle/frameworks/helmet/Helmet.Required.Setting.model.yml`
*/
extensible predicate requiredHelmetSecuritySetting(string name);

Просмотреть файл

@ -24,7 +24,7 @@ A suitable [model pack](https://docs.github.com/en/code-security/codeql-cli/usin
name: my-org/javascript-helmet-insecure-config-model-pack
version: 1.0.0
extensionTargets:
codeql/java-all: '*'
codeql/javascript-all: '*'
dataExtensions:
- models/**/*.yml
```

Просмотреть файл

@ -12,30 +12,8 @@
*/
import javascript
import DataFlow
import semmle.javascript.frameworks.ExpressModules
class HelmetProperty extends DataFlow::Node instanceof DataFlow::PropWrite {
ExpressLibraries::HelmetRouteHandler helmet;
HelmetProperty() {
this = helmet.(DataFlow::CallNode).getAnArgument().getALocalSource().getAPropertyWrite()
}
ExpressLibraries::HelmetRouteHandler getHelmet() { result = helmet }
predicate isFalse() { DataFlow::PropWrite.super.getRhs().mayHaveBooleanValue(false) }
string getName() { result = DataFlow::PropWrite.super.getPropertyName() }
predicate isImportantSecuritySetting() {
// read from data extensions to allow enforcing custom settings
// defaults are located in javascript/ql/lib/semmle/frameworks/helmet/Helmet.Required.Setting.model.yml
requiredHelmetSecuritySetting(this.getName())
}
}
extensible predicate requiredHelmetSecuritySetting(string name);
import semmle.javascript.frameworks.helmet.Helmet
from HelmetProperty helmetProperty, ExpressLibraries::HelmetRouteHandler helmet
where