ember-cli / ember-cli/ember-cli-preprocess-registry

No way to block a child addon from loading

Abierto
#26 1 comentario 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
JavaScript
Estrellas
1
Forks
11
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

I have an addon, `parent`, that has as a `dependency`, another addon, `insecure-child`. I'd like to include `parent` in my application, but `insecure-child` has an unpatched security problem, so I'd like to block it. (It's critical only to parts of `parent` that my application doesn't use.)

Things I've tried:

### Blacklist
```js
// my-app/ember-cli-build.js
let app = new EmberApp(defaults, {
addons: { blacklist: ['insecure-child'] }
})
```
ember-cli throws an exception saying that `child` is not found.

### Monkey-Patch `shouldIncludeChildAddon`

```js
// my-ap/ember-cli-build.js
const EmberAddon = require('ember-cli/lib/models/addon')
const shouldIncludeChildAddon = EmberAddon.prototype.shouldIncludeChildAddon
EmberAddon.prototype = function(child) {
return child.name === 'insecure-child' ? false : shouldIncludeChildAddon.call(this, child)
}
```

This doesn't work because ember-cli-preprocessor-registry runs before `ember-cli-build` loads.

### Configurable child blacklist

If I control `parent`, I can override `shouldIncludeChildAddon` there. My first instinct was
```js
// parent/index.js
config(environment, appConfig) {
this.addonBlacklist = (appConfig.parent.addons || {}).blacklist || []
}

shouldIncludeChildAddon(child) {
return !this.addonBlacklist.includes(child.name)
}
```
The problem with this is that `shouldIncludeChildAddon` is called before `config` is called. I could call `this.parent.config()`, but I don't have an `environment` to pass it.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

Empieza leyendo el flujo de carga de addons alrededor de shouldIncludeChildAddon y el timing de ember-cli-preprocess-registry descrito en el issue. Compara el manejo de la blacklist en ember-cli-build.js con la configuración propuesta en parent/index.js, y sigue cuándo se llama a config. La solución terminada debería proporcionar una forma compatible para que una aplicación impida que se cargue un addon hijo determinado sin depender de monkey-patching.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript
Área
build-system
Tipo de issue
Nueva funcionalidad
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.