File tree Expand file tree Collapse file tree 3 files changed +31
-3
lines changed Expand file tree Collapse file tree 3 files changed +31
-3
lines changed Original file line number Diff line number Diff line change 11const spawn = require ( 'child_process' ) . spawn ;
2+ const validateOptions = require ( 'schema-utils' ) ;
3+ const schema = require ( './schema.json' ) ;
24
35class HTMLValidatePlugin {
46 constructor ( options = { } ) {
7+ // validate the options being passed through the plugin options
8+ validateOptions ( schema , options , 'HTMLValidatePlugin' ) ;
9+
510 Object . assign (
611 this ,
712 {
@@ -41,9 +46,11 @@ class HTMLValidatePlugin {
4146
4247 runCliBasedOnScope ( userParams , spawnParams ) {
4348 /*
44- arguments are in an array and shell option is "false" by default; this is better for security
45- https://stackoverflow.com/a/50424976d
46- https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options
49+ Attempts at better security:
50+ - schema utils used to validate user input
51+ - spawn command (by default) is not exec under a shell env
52+ https://gist.github.com/evilpacket/5a9655c752982faf7c4ec6450c1cbf1b
53+ https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options
4754 */
4855 return this . global
4956 ? spawn ( 'html-validate' , [ `${ userParams } ` ] , spawnParams )
Original file line number Diff line number Diff line change 2525 "homepage" : " https://github.com/waldronmatt/html-validate-webpack-plugin#readme" ,
2626 "devDependencies" : {
2727 "prettier" : " ^2.2.1"
28+ },
29+ "dependencies" : {
30+ "schema-utils" : " ^1.0.0"
2831 }
2932}
Original file line number Diff line number Diff line change 1+ {
2+ "type" : " object" ,
3+ "properties" : {
4+ "path" : {
5+ "type" : " string"
6+ },
7+ "extensions" : {
8+ "type" : " array"
9+ },
10+ "config" : {
11+ "type" : " string"
12+ },
13+ "global" : {
14+ "type" : " boolean"
15+ }
16+ },
17+ "additionalProperties" : false
18+ }
You can’t perform that action at this time.
0 commit comments