Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Subresource Integrity With Angular-Cli

I was wondering if anyone knew of a possible way to activate Subresource Integrety with Angular-Cli. According to the following link: GitHub Pull Request It would be a feature (or a future feature). I was hoping to activate it but it does not seem to be active on the current versions. Is there another way to use Subresource Integrety with Angular-Cli?

like image 501
Alex L Avatar asked Jul 17 '17 06:07

Alex L


People also ask

How to add subresource integrity to your angular-CLI build script?

Thanks to the angular-cli team there is already an option to add the subresource integrity to your files by simply appending —subresource-integrity to your build script: Once the flag is added, the cli will automatically generate a hash for the application resources and add to the index.html when running npm run build:

What is subresource integrity Sri?

Subresource Integrity. Jump to: Subresource Integrity (SRI) is a security feature that enables browsers to verify that resources they fetch (for example, from a CDN) are delivered without unexpected manipulation. It works by allowing you to provide a cryptographic hash that a fetched resource must match.

What is ng build link in angular?

ng build link Compiles an Angular app into an output directory named dist/ at the given output path. Must be executed from within a workspace directory. ng build <project> [options]

How do I get data from a server in angular?

Get Data from a Server Compiles an Angular app into an output directory named dist/ at the given output path. Must be executed from within a workspace directory. The command can be used to build a project of type "application" or "library".


1 Answers

Pass the --subresource-integrity flag into your ng build command.

You can verify that it works by looking at your index.html file. You'll see the integrity attribute on linked stylesheets and scripts.

SRI requires v1.5.0+ of the CLI.

E.G. ng build --subresource-integrity

like image 175
Taul Avatar answered Sep 22 '22 10:09

Taul