{"id":25051088,"url":"https://github.com/petermosmans/javascript-secure-coding","last_synced_at":"2025-10-20T04:38:38.951Z","repository":{"id":274041277,"uuid":"921701650","full_name":"PeterMosmans/javascript-secure-coding","owner":"PeterMosmans","description":"Several (in)secure JavaScript code examples, meant to learn more about secure coding in JavaScript","archived":false,"fork":false,"pushed_at":"2025-01-29T16:34:24.000Z","size":87,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-06T09:19:40.428Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PeterMosmans.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-24T13:01:05.000Z","updated_at":"2025-01-29T16:34:27.000Z","dependencies_parsed_at":"2025-01-24T14:45:00.134Z","dependency_job_id":null,"html_url":"https://github.com/PeterMosmans/javascript-secure-coding","commit_stats":null,"previous_names":["petermosmans/javascript-secure-coding"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterMosmans%2Fjavascript-secure-coding","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterMosmans%2Fjavascript-secure-coding/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterMosmans%2Fjavascript-secure-coding/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterMosmans%2Fjavascript-secure-coding/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PeterMosmans","download_url":"https://codeload.github.com/PeterMosmans/javascript-secure-coding/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246418700,"owners_count":20773935,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-06T09:19:44.911Z","updated_at":"2025-10-20T04:38:38.874Z","avatar_url":"https://github.com/PeterMosmans.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Secure Coding in JavaScript\n\nThis is a JavaScript / Node.js demo application mean to practice secure coding.\nMake sure to NOT use this code anytime in production, as the examples contain\ndeliberate security vulnerabilities.\n\n## Prerequisites\n\nHave `docker`, `node` and optionally `openssl` installed.\n\n## Installation\n\n```console\ngit clone https://github.com/PeterMosmans/javascript-secure-coding \\\n  \u0026\u0026 cd javascript-secure-coding \\\n  \u0026\u0026 ./installer.sh\n```\n\nThis will:\n\n- clone the repository,\n- check the prerequisites,\n- generate a self-signed certificate when `openssl` is installed,\n- copy `defaults/.env` to `.env` (unless there is already a `.env` present), and\n- install the required dependencies.\n\nOptionally check the `.env` file: In order for the demos to work, the hosts\nmentioned in `.env` should resolve to accessible IP addresses. This might\ninclude modifying your local `hosts` file.\n\n## Run all servers\n\n```console\n./start-servers.sh\n```\n\nThis will start all servers in the background, including the Docker container.\n\n## Stop all servers\n\n```console\n./stop-servers.sh\n```\n\n# ⚠ IMPORTANT ⚠\n\nDon't forget to trust the self-signed certificate _for each one of the\nservices_, as this certificate is not trusted by default.\n\nYou can do this by visiting https://localhost:3000/test , accepting the\nself-signed certificate for this site, then by clicking on \"browse to\nauthentication URL\" and \"browse to API URL\", and accepting the self-signed\ncertificates **for each one of the servers**.\n\nIf you don't trust the certificates manually, then the demos will not work.\n\nWhen manually starting the services, source the `.env` file, as the environment\nfile contains important variables required for the various services to run.\n\n## Architecture\n\nThe web server has the following functionality:\n\n- Input output page `/` - dynamically display output, filter, sanitize, and\n  validate data\n- Authentication page `/authentication`: log in, reset session\n- Authorization page `/authorization` - perform an action as authenticated user,\n  validate access permissions of a token\n- Protected authorization page `/authorization-protected` - perform a protected,\n  validated action as authenticated user, validate access permissions of a token\n- Test page `/test` - Check whether the demo site is correctly functioning\n\nFurthermore there are a few variations on the input output page:\n\n- `/csp` - Apply a simple Content Security Policy header\n- `/frame` - Apply a bit more advanced Content Security Policy header\n\n## Copyright / License\n\nGreat that you're using this code, hopefully you'll find it useful! All that I'm\nasking is that you properly attribute the author\n([Peter Mosmans](https://github.com/PeterMosmans)), and respect the\n[GPLv3 license](LICENSE).\n\nThis demo uses [Cerbos](https://github.com/cerbos/cerbos) and\n[DOMPurify](https://github.com/cure53/DOMPurify), both licensed under the Apache\nLicense.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetermosmans%2Fjavascript-secure-coding","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpetermosmans%2Fjavascript-secure-coding","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetermosmans%2Fjavascript-secure-coding/lists"}