File tree 2 files changed +15
-0
lines changed
packages/@angular/cli/models/webpack-configs
2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -112,6 +112,12 @@ export function getCommonConfig(wco: WebpackConfigOptions) {
112
112
}
113
113
}
114
114
115
+ // Prevent asset configurations from reading files outside of the project.
116
+ if ( ! asset . input . startsWith ( projectRoot ) ) {
117
+ const message = 'An asset cannot be read from a location outside the project.' ;
118
+ throw new SilentError ( message ) ;
119
+ }
120
+
115
121
// Ensure trailing slash.
116
122
if ( isDirectory ( path . resolve ( asset . input ) ) ) {
117
123
asset . input += '/' ;
Original file line number Diff line number Diff line change @@ -55,6 +55,15 @@ export default function () {
55
55
} ) )
56
56
. then ( ( ) => expectToFail ( ( ) => ng ( 'build' ) ) )
57
57
58
+ // This asset should also fail from reading from outside the project.
59
+ . then ( ( ) => updateJsonFile ( '.angular-cli.json' , configJson => {
60
+ const app = configJson [ 'apps' ] [ 0 ] ;
61
+ app [ 'assets' ] = [
62
+ { 'glob' : '**/*' , 'input' : '/temp-folder/outside/of/project' , 'output' : 'temp' }
63
+ ] ;
64
+ } ) )
65
+ . then ( ( ) => expectToFail ( ( ) => ng ( 'build' ) ) )
66
+
58
67
// Add asset config in .angular-cli.json.
59
68
. then ( ( ) => updateJsonFile ( '.angular-cli.json' , configJson => {
60
69
const app = configJson [ 'apps' ] [ 0 ] ;
You can’t perform that action at this time.
0 commit comments