Skip to content

Commit cdf5cfc

Browse files
committed
warning message
1 parent ed3dc72 commit cdf5cfc

File tree

1 file changed

+8
-2
lines changed
  • packages/@angular/cli/models/webpack-configs

1 file changed

+8
-2
lines changed

packages/@angular/cli/models/webpack-configs/common.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as webpack from 'webpack';
22
import * as path from 'path';
33
import * as CopyWebpackPlugin from 'copy-webpack-plugin';
4+
import chalk from 'chalk';
45
import { NamedLazyChunksWebpackPlugin } from '../../plugins/named-lazy-chunks-webpack-plugin';
56
import { InsertConcatAssetsWebpackPlugin } from '../../plugins/insert-concat-assets-webpack-plugin';
67
import { extraEntryParser, getOutputHashFormat, AssetPattern } from './utils';
@@ -114,13 +115,18 @@ export function getCommonConfig(wco: WebpackConfigOptions) {
114115
}
115116

116117
// 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.`
119121
+ 'You can override this message by setting the `allowOutsideReadDir` '
120122
+ 'property on the asset to true in the CLI configuration.';
121123
throw new SilentError(message);
122124
}
123125

126+
if (asset.allowOutsideOutDir) {
127+
console.log(chalk.yellow('The allowOutsideOutDir option is on that could be a security risk'));
128+
}
129+
124130
// Ensure trailing slash.
125131
if (isDirectory(path.resolve(asset.input))) {
126132
asset.input += '/';

0 commit comments

Comments
 (0)