web:javascript:nodejs:toc
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
web:javascript:nodejs:toc [2019/06/20 04:00] – [Tests] sgariepy | web:javascript:nodejs:toc [2023/10/03 18:43] (Version actuelle) – sgariepy | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
+ | ====== NodeJS ====== | ||
+ | |||
+ | * [[web: | ||
+ | * [[web: | ||
+ | * [[web: | ||
+ | * [[web: | ||
+ | * [[web: | ||
+ | * [[web: | ||
+ | * [[web: | ||
+ | * [[web: | ||
+ | * [[web: | ||
+ | |||
+ | |||
====== Installation ====== | ====== Installation ====== | ||
Ligne 53: | Ligne 66: | ||
Source : [[http:// | Source : [[http:// | ||
+ | |||
+ | |||
+ | |||
+ | ====== Sécurité avec Node, Express et AngularJS ====== | ||
+ | |||
+ | ===== Sécurité de base ===== | ||
+ | |||
+ | $ npm audit | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ===== Protéger les données de l' | ||
+ | |||
+ | |||
+ | ===== XSS ===== | ||
+ | |||
+ | La façon traditionnelle de se procurer des informations et d' | ||
+ | |||
+ | |||
+ | ==== Prévention ==== | ||
+ | |||
+ | * Input Validation, Sanitization and Escaping | ||
+ | * Content Security Policy : Create a contract between your server and the browser for permitted origins. | ||
+ | |||
+ | ===== Content Security Policy ===== | ||
+ | |||
+ | |||
+ | Dans l' | ||
+ | |||
+ | Un exemple de valeur est : | ||
+ | |||
+ | content-security-policy: | ||
+ | | ||
+ | |||
+ | Supporté par les navigateurs récents, pas IE8, IE9 et IE11 supporte '' | ||
+ | |||
+ | Pour plus de détails, voir [[https:// | ||
+ | |||
+ | |||
+ | |||
+ | ===== XSS Filters ===== | ||
+ | |||
+ | |||
+ | Le [[https:// | ||
+ | |||
+ | $ npm install xss-filters --save | ||
+ | |||
+ | ===== Lusca ===== | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | $ npm install lusca --save | ||
+ | |||
+ | |||
+ | <code javascript> | ||
+ | const lusca = require(' | ||
+ | |||
+ | app.use(lusca.csp({ | ||
+ | policy: { | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | } | ||
+ | })); | ||
+ | </ | ||
+ | |||
+ | Puisqu' | ||
+ | |||
+ | <code html> | ||
+ | < | ||
+ | <html ng-app=" | ||
+ | <!-- reste du fichier ignoré. --> | ||
+ | </ | ||
+ | |||
+ | jQuery charge des images avec '' | ||
+ | <code javascript> | ||
+ | ' | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Encrypter le trafic ===== | ||
+ | |||
+ | Pour encrypter le trafic entre le serveur Node et le client, il faut utiliser le HTTPS. | ||
+ | |||
+ | Pour se faire, il faut créer un certificat, soit par une autorité pour la production, soit un [[: | ||
+ | |||
+ | Ensuite, il faut utiliser les modules '' | ||
+ | |||
+ | <code javascript> | ||
+ | const https = require(' | ||
+ | const fs = require(' | ||
+ | |||
+ | const options = { | ||
+ | key: fs.readFileSync(' | ||
+ | cert: fs.readFileSync(' | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | Ensuite, au lieu du traditionnel '' | ||
+ | |||
+ | <code javascript> | ||
+ | https.createServer(options, | ||
+ | console.log(' | ||
+ | }); | ||
+ | </ | ||
+ | |||
+ | ===== Autre méthode ===== | ||
+ | |||
+ | |||
+ | XSS occurs when the attacker injects executable JavaScript code into the HTML response. | ||
+ | |||
+ | To mitigate these attacks, you have to set flags on the set-cookie HTTP header: | ||
+ | |||
+ | HttpOnly - this attribute is used to help prevent attacks such as cross-site scripting since it does not allow the cookie to be accessed via JavaScript. | ||
+ | secure - this attribute tells the browser to only send the cookie if the request is being sent over HTTPS. | ||
+ | |||
+ | |||
+ | ===== Autres sujets ===== | ||
+ | |||
+ | * NodeJS Key-vault secrets | ||
+ | |||
+ | |||
+ | |||
+ | ===== Ressources ===== | ||
+ | |||
+ | * [[http:// | ||
+ | * https:// | ||
+ | * [[https:// | ||
Ligne 62: | Ligne 205: | ||
* [[https:// | * [[https:// | ||
* '' | * '' | ||
+ | * https:// | ||
+ | |||
+ | |||
+ | ===== Debugging avec NodeJS ===== | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | $ node --inspect hello.js | ||
+ | |||
+ | Ceci permet d' | ||
+ | |||
+ | $ node --inspect-brk hello.js | ||
+ | |||
+ | CLI debugger: | ||
+ | |||
+ | $ node inspect hello.js | ||
+ | |||
+ | |||
+ | |||
+ | Dans Chrome : '' | ||
+ | |||
+ | Fonctionne aussi avec '' | ||
+ | |||
+ | |||
+ | Outils qui lancent Devtools: | ||
+ | * june07.com/ | ||
+ | * github.com/ | ||
+ | * github.com/ | ||
+ | |||
+ | |||
+ | |||
+ | ===== Autres outils ===== | ||
+ | |||
+ | * [[https:// | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
====== CommonJS ====== | ====== CommonJS ====== |
web/javascript/nodejs/toc.txt · Dernière modification : 2023/10/03 18:43 de sgariepy