File tree 1 file changed +8
-2
lines changed
packages/@angular/cli/models/webpack-configs
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 1
1
import * as webpack from 'webpack' ;
2
2
import * as path from 'path' ;
3
3
import * as CopyWebpackPlugin from 'copy-webpack-plugin' ;
4
+ import chalk from 'chalk' ;
4
5
import { NamedLazyChunksWebpackPlugin } from '../../plugins/named-lazy-chunks-webpack-plugin' ;
5
6
import { InsertConcatAssetsWebpackPlugin } from '../../plugins/insert-concat-assets-webpack-plugin' ;
6
7
import { extraEntryParser , getOutputHashFormat , AssetPattern } from './utils' ;
@@ -114,13 +115,18 @@ export function getCommonConfig(wco: WebpackConfigOptions) {
114
115
}
115
116
116
117
// Prevent asset configurations from reading files outside of the project.
117
- if ( ! asset . input . startsWith ( projectRoot ) && ! asset . allowOutsideReadDir ) {
118
- const message = `${ asset . input } cannot be read from a location outside the project.`
118
+ const projectRelativeInput = path . relative ( projectRoot , asset . input ) ;
119
+ if ( ( projectRelativeInput . startsWith ( '..' ) || path . isAbsolute ( projectRelativeInput ) ) && ! asset . allowOutsideReadDir ) {
120
+ const message = `${ asset . input } cannot be read from a location outside the project.`
119
121
+ 'You can override this message by setting the `allowOutsideReadDir` '
120
122
+ 'property on the asset to true in the CLI configuration.' ;
121
123
throw new SilentError ( message ) ;
122
124
}
123
125
126
+ if ( asset . allowOutsideOutDir ) {
127
+ console . log ( chalk . yellow ( 'The allowOutsideOutDir option is on that could be a security risk' ) ) ;
128
+ }
129
+
124
130
// Ensure trailing slash.
125
131
if ( isDirectory ( path . resolve ( asset . input ) ) ) {
126
132
asset . input += '/' ;
You can’t perform that action at this time.
0 commit comments