Skip to content

Commit b1c1fee

Browse files
authored
Merge pull request #12 from Jeymz/main
feat: Add Dockerfile, lint workflow, and enhance server configuration
2 parents 4933a06 + cf42c44 commit b1c1fee

File tree

12 files changed

+199
-114
lines changed

12 files changed

+199
-114
lines changed

.dockerignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.env
2+
.git
3+
.github
4+
.gitignore
5+
*.pfx
6+
node_modules
7+
tests
8+
Dockerfile
9+
renovate.json
10+
eslint.config.mjs
11+
copilot-instructions.node_modules.gitlab-ci.yml
12+
.markdownlint.yml
13+
.markdownlintignore

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
server.port=8080
22
server.hostname=localhost
3+
server.ssl=false
4+
server.ssl.pfx=localhost.pfx
5+
server.ssl.pfxPassphrase='PFX_PASSPHRASE'
36
logger.transports.console.enabled=true
47
logger.transports.console.level=info
58
logger.transports.amqp.enabled=false

.github/workflows/markdownlint.yml renamed to .github/workflows/lint.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Markdown Lint
1+
name: Lint
22

33
on:
44
pull_request:
@@ -21,8 +21,8 @@ jobs:
2121
- name: Clear npm cache
2222
run: npm cache clean --force
2323

24-
- name: Install markdownlint-cli
24+
- name: Install dependencies
2525
run: npm install
2626

27-
- name: Run markdownlint
27+
- name: Run lint
2828
run: npm run lint

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.env
2-
node_modules/
2+
node_modules/
3+
*.pfx

Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM node:lts-bullseye-slim
2+
3+
ENV NODE_ENV=production
4+
ENV server.port=8080
5+
ENV server.hostname=localhost
6+
ENV logger.transports.console.enabled=true
7+
ENV logger.transports.console.level=info
8+
9+
RUN apt-get update
10+
RUN apt-get install -y --no-install-recommends dumb-init
11+
12+
EXPOSE 8080
13+
14+
WORKDIR /usr/src/app
15+
16+
COPY --chown=node:node . .
17+
18+
RUN npm install --omit=dev
19+
20+
USER node
21+
22+
HEALTHCHECK CMD curl http://localhost:8080/health || exit 1
23+
24+
ENTRYPOINT ["dumb-init", "node", "server.js"]

README.md

Lines changed: 82 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -2,53 +2,37 @@
22

33
[![Verified on MseeP](https://mseep.ai/badge.svg)](https://mseep.ai/app/1a935343-666d-457a-b210-2e0d27e9ef81)
44

5-
A customizable `.github/copilot-instructions.md` file that guides **GitHub Copilot** toward **secure coding defaults** across **Java, Node.js, and C#**.
5+
A comprehensive toolkit to guide **GitHub Copilot** toward **secure coding practices**. This project includes customizable instructions and security-focused prompts to help development teams identify and mitigate security risks effectively.
66

7-
Designed for security-conscious development teams, this config helps Copilot suggest safer code patterns, avoid common vulnerabilities, and reinforce good practices — without slowing down your workflow.
7+
Designed for security-conscious teams, this configuration ensures Copilot suggests safer code patterns, avoids common vulnerabilities, and reinforces best practices — all without disrupting your workflow.
88

99
---
1010

1111
## 🔐 What's Inside
1212

13-
This Copilot configuration includes:
13+
This project offers:
1414

15-
- **Secure-by-default guidance** for all languages (input validation, secret handling, safe logging)
15+
- **Secure-by-default guidance** for all languages (e.g., input validation, secret handling, safe logging).
1616
- **Language-specific secure patterns**:
1717
- ☕ Java
1818
- 🟩 Node.js
1919
- 🟦 C#
2020
- 🐍 Python
21-
- **"Do Not Suggest" lists** to block risky Copilot completions (e.g. `eval`, inline SQL, insecure deserialization)
22-
- **AI hallucination protections** (package spoofing, non-existent APIs, misinformation risks)
23-
- **Mentorship-style dev tips** to help newer engineers build safe habits over time
24-
- **An MCP server** to make using these prompts in other projects easier
21+
- **"Do Not Suggest" lists** to block risky Copilot completions (e.g., `eval`, inline SQL, insecure deserialization).
22+
- **AI hallucination protections** to prevent package spoofing, non-existent APIs, and misinformation risks.
23+
- **Mentorship-style tips** to help newer engineers build secure coding habits.
24+
- **An MCP server** for seamless integration of these prompts into other projects.
2525

2626
---
2727

28-
## 🧠 Using Prompts for Code Reviews (Copilot Chat)
29-
30-
If your organization has [Copilot Prompt Customization](https://code.visualstudio.com/docs/copilot/copilot-customization#_prompt-files-experimental) enabled, you can guide Copilot Chat to run secure code audits using the included prompt files.
31-
32-
1. Open any file in your IDE (e.g., `tests/secret-hardcode.js`)
33-
2. Open the Copilot Chat sidebar
34-
3. Type:
35-
36-
```bash
37-
@prompt .github/prompts/check-for-secrets.md
38-
```
39-
40-
Copilot will scan the file using the selected prompt and return flagged issues, reasoning, and remediation tips.
41-
42-
> ℹ️ Note: If your org disables `chat.promptFiles`, you can manually paste the prompt contents into Copilot Chat or use them in PRs, checklists, and reviews.
43-
4428
## 🗂️ Prompt Catalogue
4529

46-
Explore the available prompt files and their intended purpose:
30+
Explore the available prompts and their intended use cases:
4731

4832
| Prompt | Description | Intended Use |
4933
| --- | --- | --- |
5034
| [assess-logging.prompt.md](prompts/assess-logging.prompt.md) | Identify unsafe logging and exposure of sensitive data. | Audit log output for leaks and recommend safer patterns. |
51-
| [business-logic-review.prompt.md](prompts/business-logic-review.prompt.md) | Analyze overall business logic flow and decision making. | Map application behaviour and critique critical logic paths. |
35+
| [business-logic-review.prompt.md](prompts/business-logic-review.prompt.md) | Analyze overall business logic flow and decision making. | Map application behavior and critique critical logic paths. |
5236
| [check-access-controls.prompt.md](prompts/check-access-controls.prompt.md) | Audit authorization and access control weaknesses. | Ensure RBAC/ABAC enforcement and consistent permission checks. |
5337
| [check-for-secrets.prompt.md](prompts/check-for-secrets.prompt.md) | Detect hardcoded secrets and credentials. | Locate embedded keys or tokens and suggest secure storage. |
5438
| [check-for-unvalidated-genai-acceptances.prompt.md](prompts/check-for-unvalidated-genai-acceptances.prompt.md) | Find unvalidated AI-generated code or hallucinated assets. | Verify that AI suggestions are real, tested, and documented. |
@@ -57,83 +41,93 @@ Explore the available prompt files and their intended purpose:
5741
| [secure-code-review.prompt.md](prompts/secure-code-review.prompt.md) | Perform a comprehensive security review of the codebase. | Conduct an end-to-end audit for security issues. |
5842
| [validate-input-handling.prompt.md](prompts/validate-input-handling.prompt.md) | Check for missing or unsafe input validation. | Evaluate request handling for validation and sanitization gaps. |
5943

60-
## 🧪 Testing the Prompts
61-
62-
The `tests/` folder contains small, focused files designed to trigger specific security prompts:
63-
64-
| File | Targets |
65-
|--------------------------------|-----------------------------------|
66-
| `secret-hardcode.js` | check-for-secrets.md |
67-
| `unvalidated-input.java` | validate-input-handling.md |
68-
| `insecure-api.cs` | scan-for-insecure-apis.md |
69-
| `logs-sensitive-data.go` | assess-logging.md |
70-
| `weak-auth-flow.ts` | review-auth-flows.md |
71-
| `overtrusted-genai-snippet.js` | unvalidated-genai-acceptances.md |
72-
73-
To run a test:
74-
75-
1. Open a file in `tests/`
76-
2. Run the related prompt in Copilot Chat
77-
3. Review and refine based on Copilot’s feedback
78-
7944
---
8045

8146
## 📦 How to Use in a Real Project
8247

83-
### Static Files
48+
### Leveraging Static Files
8449

8550
1. Copy the `copilot-instructions.md` file into your repo under:
8651
`.github/copilot-instructions.md`
8752

8853
2. Drop the prompts you want into:
8954
`.github/prompts/`
9055

91-
3. Use prompt-driven reviews in Copilot Chat during coding, PRs, or audits
56+
3. Open the prompt you wish to run within your IDE
9257

93-
### Leveraging the included MCP Server
58+
4. Click the `Run Prompt` button to the top-right of the file
9459

95-
The MCP server is designed to simplify the integration of secure coding prompts into your development workflow. Follow these steps to ensure a smooth experience:
60+
![Run Prompt Button](images/example-run_prompt.png)
9661

97-
#### 1. Setting Up the MCP Server
62+
> ℹ️ **Note**: If you don't see the run prompt button; check to make sure the `Chat: Prompt Files` functionality is enabled in your settings
63+
> ![Chat Prompt Files Setting](images/example-chat_prompt_files.png)
9864
99-
```bash
100-
npm install
101-
cp .env.example .env
102-
npm start
103-
```
65+
### Leveraging the MCP Server
10466

105-
- **`npm install`**: Installs all required dependencies.
106-
- **`cp .env.example .env`**: Creates a `.env` file for configuration. Update it with your specific settings.
107-
- **`npm start`**: Launches the MCP server on `http://localhost:8080/mcp`.
67+
The MCP server simplifies the integration of secure coding prompts into your workflow. Follow these steps:
10868

109-
#### Environment Variables
69+
#### Run MCP from source
11070

111-
The MCP server reads configuration from a `.env` file. The following variables can be set:
71+
1. Install dependencies
11272

113-
| Variable | Description | Default | Required |
114-
| --- | --- | --- | --- |
115-
| `server.port` | Port the MCP server listens on. | `8080` | Optional |
116-
| `server.hostname` | Hostname the server binds to. | `localhost` | Optional |
117-
| `logger.transports.console.enabled` | Enable console logging output. | `false` | Optional |
118-
| `logger.transports.console.level` | Log level for console output. | `info` | Optional |
119-
| `logger.transports.amqp.enabled` | Enable AMQP-based logging. | `false` | Optional |
120-
| `logger.transports.amqp.level` | Log level for AMQP transport. | `http` | Optional |
121-
| `logger.transports.amqp.hostname` | Hostname of the AMQP broker. | `localhost` | Optional |
122-
| `logger.transports.amqp.port` | Port for the AMQP broker. | `5672` | Optional |
123-
| `logger.transports.amqp.username` | Username for AMQP authentication. | `guest` | Optional |
124-
| `logger.transports.amqp.password` | Password for AMQP authentication. | `guest` | Optional |
125-
| `logger.transports.amqp.exchange` | Exchange name used for AMQP logging. | `logs` | Optional |
126-
| `logger.transports.amqp.vhost` | Virtual host for AMQP logging. | `/logs` | Optional |
127-
| `logger.transports.amqp.heartbeat` | Heartbeat interval in seconds. | `60` | Optional |
128-
| `logger.transports.amqp.locale` | Locale for the AMQP connection. | `en_US` | Optional |
129-
| `logger.transports.amqp.type` | AMQP exchange type. | `direct` | Optional |
130-
| `logger.transports.amqp.durable` | Whether the AMQP exchange is durable. | `false` | Optional |
73+
```bash
74+
npm install
75+
```
13176

132-
All variables are optional; the server runs with these defaults. Set them in `.env` to customize behavior or enable logging transports.
77+
2. Setup environment
13378

134-
#### 2. Configuring VSCode for MCP
79+
```bash
80+
cp .env.example .env
81+
```
82+
83+
> The MCP server reads configuration from a `.env` file. Customize the following variables as needed:
84+
>
85+
> | Variable | Description | Default |
86+
> | --- | --- | --- |
87+
> | `server.port` | Port the MCP server listens on. | `8080` |
88+
> | `server.ssl`| Whether to use ssl for express server | `false` |
89+
> | `server.ssl.pfx` | Path to pfx file | `localhost.pfx` |
90+
> | `server.ssl.pfx.passphrase` | Passphrase for pfx file | `PFX_PASSPHRASE` |
91+
> | `server.hostname` | Hostname the server binds to. | `localhost` |
92+
> | `logger.transports.console.enabled` | Enable console logging output. | `false` |
93+
> | `logger.transports.console.level` | Log level for console output. | `info` |
94+
> | `logger.transports.amqp.enabled` | Enable AMQP-based logging. | `false` |
95+
> | `logger.transports.amqp.level` | Log level for AMQP transport. | `http` |
96+
> | `logger.transports.amqp.hostname` | Hostname of the AMQP broker. | `localhost` |
97+
> | `logger.transports.amqp.port` | Port for the AMQP broker. | `5672` |
98+
> | `logger.transports.amqp.username` | Username for AMQP authentication. | `guest` |
99+
> | `logger.transports.amqp.password` | Password for AMQP authentication. | `guest` |
100+
> | `logger.transports.amqp.exchange` | Exchange name used for AMQP logging. | `logs` |
101+
> | `logger.transports.amqp.vhost` | Virtual host for AMQP logging. | `/logs` |
102+
> | `logger.transports.amqp.heartbeat` | Heartbeat interval in seconds. | `60` |
103+
> | `logger.transports.amqp.locale` | Locale for the AMQP connection. | `en_US` |
104+
> | `logger.transports.amqp.type` | AMQP exchange type. | `direct` |
105+
> | `logger.transports.amqp.durable` | Whether the AMQP exchange is durable. | `false` |
106+
107+
3. Start the server
108+
109+
```bash
110+
npm start
111+
```
112+
113+
#### Run MCP in Docker
114+
115+
1. Build docker container
116+
117+
```bash
118+
docker build -t copilot-security-mcp .
119+
```
120+
121+
2. Run docker container
122+
123+
```bash
124+
docker run -d -p 8080:8080 copilot-security-mcp
125+
```
126+
127+
#### Configuring VSCode for MCP
135128

136129
1. Open VSCode and run the `MCP: Open User Configuration` command.
130+
137131
2. Add the following JSON configuration:
138132

139133
```json
@@ -147,16 +141,18 @@ All variables are optional; the server runs with these defaults. Set them in `.e
147141
```
148142

149143
3. Save the configuration.
144+
150145
4. Navigate to the Extensions menu in VSCode.
146+
151147
5. Locate the `copilot-instructions-mcp` server, click the settings cog, and select `start server`.
152148

153-
#### 3. Using MCP with GitHub Copilot
149+
#### Using MCP with GitHub Copilot
150+
151+
1. Open GitHub Copilot Chat.
154152

155-
- Open GitHub Copilot Chat.
156-
- Ask it to run any of the prompts against your repository or specific files.
157-
- Example: `Please request and run the secure code review prompt using the MCP server.`
153+
2. Ask it to run any of the prompts against your repository or specific files.
158154

159-
This setup ensures developers can easily leverage the MCP server to enhance their secure coding practices.
155+
**Example:** `Please get and run the secure code review prompt.`
160156

161157
---
162158

@@ -180,7 +176,7 @@ Use these npm scripts to work on the project:
180176
| `npm run lint` | Runs ESLint and Markdownlint to verify code and docs. |
181177
| `npm run lint:fix` | Attempts to automatically fix linting issues. |
182178

183-
**Recommended workflow:** run `npm run lint` (and `npm run lint:fix` if needed) before committing or opening a PR.
179+
**Recommended workflow:** Run `npm run lint` (and `npm run lint:fix` if needed) before committing or opening a PR.
184180

185181
---
186182

38.2 KB
Loading

images/example-run_prompt.png

26.1 KB
Loading

0 commit comments

Comments
 (0)