File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
packages/@angular/cli/models/webpack-configs Expand file tree Collapse file tree 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) {
112112 }
113113 }
114114
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+
115121 // Ensure trailing slash.
116122 if ( isDirectory ( path . resolve ( asset . input ) ) ) {
117123 asset . input += '/' ;
Original file line number Diff line number Diff line change @@ -55,6 +55,15 @@ export default function () {
5555 } ) )
5656 . then ( ( ) => expectToFail ( ( ) => ng ( 'build' ) ) )
5757
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+
5867 // Add asset config in .angular-cli.json.
5968 . then ( ( ) => updateJsonFile ( '.angular-cli.json' , configJson => {
6069 const app = configJson [ 'apps' ] [ 0 ] ;
You can’t perform that action at this time.
0 commit comments