Skip to content

Commit 054417e

Browse files
committed
Initial commit
1 parent fb2f29e commit 054417e

File tree

517 files changed

+71351
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

517 files changed

+71351
-0
lines changed

.devcontainer/devcontainer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"onCreateCommand": "sudo apt-get update && sudo apt install -y nodejs",
3+
"postCreateCommand": "npm install express body-parser express-rate-limit"
4+
}

.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
### VSCODE ###
2+
.vscode/*
3+
!.vscode/settings.json
4+
!.vscode/tasks.json
5+
!.vscode/launch.json
6+
!.vscode/extensions.json
7+
!.vscode/*.code-snippets
8+
9+
# Local History for Visual Studio Code
10+
.history/
11+
12+
# Built Visual Studio Code Extensions
13+
*.vsix
14+
15+
# Misc
16+
.sass-cache
17+
connect.lock
18+
typings
19+
20+
# Logs
21+
logs
22+
*.log
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
27+
# System Files
28+
.DS_Store
29+
Thumbs.db

README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Code Security Challenge by the GitHub Security Lab
2+
3+
## 👋 Welcome
4+
5+
The mission of the GitHub Security Lab is to inspire and enable the community to secure the open source software we all depend on. Today, we are excited to present you a code security challenge inspired from real-world code, with which you can feel part of us through the thrill of finding and fixing a security issue!
6+
7+
## 🎮 Time to PLAY!
8+
9+
#### 🛠️ Clone the repository
10+
11+
1. Click **Use this template** followed by **Create a new repository**.
12+
2. In the new tab, most of the prompts will automatically fill in for you. For the rest:
13+
- For owner, choose your personal account.
14+
- For repository name, choose a name of your preference.
15+
- For description, you can leave it blank.
16+
- For visibility, choose **Public** if you wish to use code scanning for free, with the downside of others being able to see your code. Choose **Private** if you wish to keep your code private, with the downside of not being able to use code scanning as you will need a paid plan.
17+
1. Click the **Create repository** button at the bottom of the form.
18+
1. You can now proceed to the following section.
19+
20+
#### 💻 Run it in seconds via Codespaces (Recommended)
21+
22+
The challenge is configured to run instantly with Codespaces, a fully configured dev environment in the cloud with up to 60 hours a month free. For more information, checkout [Codespaces](https://docs.github.com/en/codespaces/overview). If you prefer to work locally, please follow the local installation guide in the next section.
23+
24+
To create a codespace:
25+
1. Click the **Code** drop down button in the upper-right of your repository navigation bar.
26+
1. Click **Create codespace on main**.
27+
1. After creating a codespace, wait for around a minute for the background installations to complete.
28+
1. Upon completion, ignore any files that may have changed such as `node_modules` and `package-lock.json`. There's no need to commit these changes.
29+
1. You can now scroll to the 🚀 PLAY section!
30+
31+
#### 💻️ OR Run it locally
32+
33+
Please note: You don't need this step if you are using Codespaces, skip to the next section!
34+
35+
1. Install [Nodejs](https://nodejs.org/en/download).
36+
1. Install express, body-parser and express-rate-limit using npm by running the following command in your terminal:
37+
38+
```bash
39+
npm install express body-parser express-rate-limit
40+
```
41+
42+
Once installation has completed, clone your repository to your local machine and install required dependencies.
43+
44+
1. From your repository, click the **Code** drop down button in the upper-right of your repository navigation bar.
45+
1. Select the `Local` tab from the menu.
46+
1. Copy the repository's URL.
47+
1. In your terminal, change the working directory to the location where you want the cloned directory.
48+
1. Type `git clone` and paste the copied URL.
49+
1. Press **Enter** to create your local clone.
50+
1. Change the working directory to the cloned directory.
51+
52+
#### 🚀 PLAY!
53+
54+
1. Open a terminal and run:
55+
`node server.js`
56+
1. If you're inside a Codespace, you will notice a prompt appearing on the bottom right corner. Click **Open in browser**. If you're running the challenge locally, open a web browser and navigate to `http://localhost:3000/`.
57+
1. Spot the security issue by reviewing the code in `script.js`, `server.js`, `index.html` and `styles.css`.
58+
1. If you enjoy this challenge, we have 10 more challenges for you in the [Secure Code Game](https://gh.io/securecodegame)!

index.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Username Page</title>
5+
<link rel="stylesheet" type="text/css" href="styles.css">
6+
<!-- Meta tag for CSRF token -->
7+
<meta name="csrf-token" content="{{csrfToken}}">
8+
</head>
9+
<body> <!-- Contains the content that is rendered on the browser -->
10+
<div id="content"> <!-- Div that contains the form and the heading. This will be replaced with the welcome message after successful form submission -->
11+
<!-- New div to wrap the text and the form. This div fits the content and aligns the text to the left -->
12+
<div style="display: inline-block; text-align: left;">
13+
<h1 id="prompt">Enter your username</h1>
14+
<form id="usernameForm"> <!-- Form for entering the username -->
15+
<input type="text" id="username" name="username" required> <!-- Text input field for the username -->
16+
<div id="errorContainer">
17+
<div id="error"></div> <!-- Div to display error messages -->
18+
</div>
19+
<input type="submit" value="Submit"> <!-- Submit button for the form -->
20+
</form>
21+
</div>
22+
</div>
23+
<script src="script.js"></script> <!-- Link to the external JavaScript file -->
24+
</body>
25+
</html>
26+
27+
<!-- Enjoying this callenge? We have 10 more for you in the [Secure Code Game](https://gh.io/securecodegame)! -->

node_modules/.bin/mime

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)