-
Notifications
You must be signed in to change notification settings - Fork 68.6k
First public PR: devcontainer JSON fix + minimal CI guardrails #40093
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
becb1e0
Initial plan
Copilot 373c7f7
Initial plan
Copilot a2c07f1
Implement comprehensive devcontainer security hardening
Copilot 64404d9
Add devcontainer port visibility automation and security hardening do…
Copilot 38433d4
Fix bullet point formatting in introduction-to-dev-containers.md
Copilot 921f8d9
Merge pull request #3 from 02ez/copilot/fix-4f8f2aa5-4a54-438f-89e7-b…
02ez 108d1a2
Docs: tighten devcontainer JSON + stable Codespaces port setup
02ez 5b0a086
Use canonical `gh codespace ports visibility`
02ez a8e8daa
Docs: canonicalize `gh codespace ports visibility` in Python setup
02ez 2fd1fbc
Docs: standardize on `gh codespace ports visibility` and unify examples
02ez 1e1c079
chore(ci): add PR summary using $GITHUB_STEP_SUMMARY
02ez 81b63dc
ci(pr-summary): robust file listing via git diff-tree + precise docs …
02ez 5aff31b
ci(pr-summary): add PR summary via $GITHUB_STEP_SUMMARY (robust diff-…
02ez f7e8e86
Update pr-summary.yml with new content
02ez 8045d10
Merge pull request #1 from 02ez/copilot/fix-53426d94-92c8-4134-9b70-d…
02ez 2900603
fix: content/actions/reference/workflows-and-actions/dockerfile-suppo…
snyk-bot 57290a5
Merge pull request #10 from 02ez/snyk-fix-dc594754af378df296533088493…
02ez caad731
fix: Dockerfile.openapi_decorator to reduce vulnerabilities
snyk-bot 4bb0bdb
Merge pull request #11 from 02ez/snyk-fix-dcb79ae3a247dad781581e023a2…
02ez fafce21
fix: package.json & package-lock.json to reduce vulnerabilities
snyk-bot 863c33b
Merge pull request #12 from 02ez/snyk-fix-ab9a4762951c40794c26c21888e…
02ez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # Security-hardened Dockerfile for devcontainer | ||
| # Uses specific pinned versions for security | ||
|
|
||
| # Use specific pinned version instead of "latest" or "dev" | ||
| ARG VARIANT="1.0.19-22-bullseye" | ||
| FROM mcr.microsoft.com/devcontainers/javascript-node:${VARIANT} | ||
|
|
||
| # Set security-focused environment variables | ||
| ENV NODE_ENV=development | ||
| ENV NPM_CONFIG_AUDIT_LEVEL=moderate | ||
|
|
||
| # Update packages and install security updates only | ||
| USER root | ||
| RUN apt-get update \ | ||
| && apt-get upgrade -y \ | ||
| && apt-get autoremove -y \ | ||
| && apt-get clean \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Switch back to non-root user for security | ||
| USER node | ||
|
|
||
| # Set working directory | ||
| WORKDIR /workspaces/docs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| # Devcontainer Security Hardening | ||
|
|
||
| This directory contains security-hardened devcontainer configurations for the GitHub Docs project. These configurations follow security best practices to minimize potential attack vectors while maintaining development functionality. | ||
|
|
||
| ## Available Configurations | ||
|
|
||
| ### 1. Default Configuration (`devcontainer.json`) | ||
| - **Security Level**: Moderate | ||
| - **Use Case**: Standard development with basic security hardening | ||
| - **Key Security Features**: | ||
| - Removed SSH daemon access | ||
| - Pinned GitHub CLI version | ||
| - Disabled automatic git fetching | ||
| - Removed external repository permissions | ||
| - Disabled automatic server startup | ||
| - Commented out automatic port visibility | ||
|
|
||
| ### 2. Hardened Configuration (`devcontainer.hardened.json`) | ||
| - **Security Level**: High | ||
| - **Use Case**: Security-focused development with minimal features | ||
| - **Key Security Features**: | ||
| - Minimal extension set | ||
| - No automatic command execution | ||
| - Manual dependency installation required | ||
| - Reduced resource allocation | ||
| - Explicit security-focused naming | ||
|
|
||
| ### 3. Team A Secure Configuration (`team-a-secure/devcontainer.json`) | ||
| - **Security Level**: High | ||
| - **Use Case**: Team-specific secure configuration | ||
| - **Key Security Features**: | ||
| - Team-specific extension subset | ||
| - Manual setup required | ||
| - Reduced resource requirements | ||
|
|
||
| ### 4. Team B Secure Configuration (`team-b-secure/devcontainer.json`) | ||
| - **Security Level**: Maximum | ||
| - **Use Case**: Ultra-secure development environment | ||
| - **Key Security Features**: | ||
| - Minimal extension set (only essential linting) | ||
| - No automatic commands whatsoever | ||
| - Workspace trust required | ||
| - Git sync confirmation required | ||
| - Minimal resource allocation | ||
|
|
||
| ## Security Improvements | ||
|
|
||
| ### Removed Security Risks | ||
| 1. **SSH Daemon**: Removed `"sshd": "latest"` feature that provided remote access | ||
| 2. **External Repository Access**: Removed automatic permissions for `github/docs-early-access` | ||
| 3. **Automatic Command Execution**: Minimized or removed automatic lifecycle commands | ||
| 4. **Unpinned Versions**: Changed `"latest"` to specific pinned versions | ||
| 5. **Auto-fetching**: Disabled automatic git fetch operations | ||
|
|
||
| ### Enhanced Security Features | ||
| 1. **Version Pinning**: All features use specific versions instead of "latest" | ||
| 2. **Minimal Extensions**: Reduced extension sets to only essential tools | ||
| 3. **Manual Operations**: Require manual approval for sensitive operations | ||
| 4. **Resource Limits**: Reduced resource allocation where appropriate | ||
| 5. **Non-root User**: Maintained non-root user execution | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Selecting a Configuration | ||
| When creating a codespace, you can choose from the available configurations: | ||
| - Default project configuration (moderately hardened) | ||
| - Team A codespace config (highly secure) | ||
| - Team B codespace config (maximum security) | ||
|
|
||
| ### Manual Setup Requirements | ||
| For security-hardened configurations: | ||
| 1. Install dependencies: `npm ci` | ||
| 2. Start the development server: `npm start` | ||
| 3. Configure port visibility manually if needed: `gh cs ports visibility 4000:public` | ||
|
|
||
| ## Security Best Practices | ||
|
|
||
| 1. **Review Configuration**: Always review devcontainer configurations before use | ||
| 2. **Minimal Permissions**: Only grant necessary permissions and features | ||
| 3. **Manual Operations**: Prefer manual over automatic operations for sensitive tasks | ||
| 4. **Version Pinning**: Use specific versions instead of "latest" tags | ||
| 5. **Regular Updates**: Keep pinned versions updated but test changes thoroughly | ||
|
|
||
| ## Migration Guide | ||
|
|
||
| ### From Standard to Hardened Configuration | ||
| 1. Switch to `devcontainer.hardened.json` or team-specific configuration | ||
| 2. Install dependencies manually: `npm ci` | ||
| 3. Start development server manually: `npm start` | ||
| 4. Configure port visibility if needed: `gh cs ports visibility 4000:public` | ||
|
|
||
| ### Custom Team Configurations | ||
| To create a custom secure configuration: | ||
| 1. Copy an existing team configuration | ||
| 2. Customize extensions and settings for your team's needs | ||
| 3. Follow the minimal permissions principle | ||
| 4. Test the configuration thoroughly | ||
|
|
||
| ## Security Considerations | ||
|
|
||
| - These configurations prioritize security over convenience | ||
| - Some automatic features have been disabled and require manual intervention | ||
| - External repository access must be granted explicitly when needed | ||
| - Review and approve all configuration changes through your security review process |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| // Hardened devcontainer configuration for enhanced security | ||
| // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: | ||
| // https://github.com/microsoft/vscode-dev-containers/tree/v0.177.0/containers/javascript-node | ||
| // - Security hardened version with minimal features and restricted access | ||
| { | ||
| "name": "docs.github.com (Security Hardened)", | ||
| "build": { | ||
| "dockerfile": "Dockerfile.hardened", | ||
| // Use specific Node version instead of generic variant | ||
| "args": { "VARIANT": "22" } | ||
| }, | ||
|
|
||
| // Minimal features - removed SSH daemon for security | ||
| "features": { | ||
| // Only essential GitHub CLI, pinned to specific version | ||
| "ghcr.io/devcontainers/features/github-cli:1": { | ||
| "version": "2.40.1" | ||
| } | ||
| }, | ||
|
|
||
| "customizations": { | ||
| "vscode": { | ||
| // Set *default* container specific settings.json values on container create. | ||
| "settings": { | ||
| "terminal.integrated.shell.linux": "/bin/bash", | ||
| "cSpell.language": ",en", | ||
| // Disable auto-fetch for security - manual fetching required | ||
| "git.autofetch": false | ||
| }, | ||
| // Minimal essential extensions only - removed potential security risks | ||
| "extensions": [ | ||
| "dbaeumer.vscode-eslint", | ||
| "sissel.shopify-liquid", | ||
| "davidanson.vscode-markdownlint", | ||
| "bierner.markdown-preview-github-styles", | ||
| "streetsidesoftware.code-spell-checker" | ||
| // Removed extensions that could pose security risks: | ||
| // - Custom extensions that might have privileged access | ||
| // - GitHub Copilot extensions (can be added manually if needed) | ||
| ] | ||
| } | ||
| // Removed codespaces repository permissions for security | ||
| // External repository access must be granted manually | ||
| }, | ||
|
|
||
| // Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
| "forwardPorts": [4000], | ||
|
|
||
| "portsAttributes": { | ||
| "4000": { | ||
| "label": "Review" | ||
| } | ||
| }, | ||
|
|
||
| // Security hardened lifecycle commands - minimal automatic execution | ||
| // Manual setup required for enhanced security | ||
| "onCreateCommand": "echo 'Security hardened container created. Run npm ci manually to install dependencies.'", | ||
| // Removed automatic npm start for security - manual startup required | ||
| // Removed automatic port visibility command - manual configuration required | ||
|
|
||
| // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. | ||
| "remoteUser": "node", | ||
|
|
||
| // Reduced resource requirements for security-focused lightweight setup | ||
| "hostRequirements": { | ||
| "memory": "8gb", | ||
| "cpus": "2" | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| { | ||
| "name": "Team A Secure Codespace Config", | ||
| "build": { | ||
| "dockerfile": "../Dockerfile.hardened", | ||
| "args": { "VARIANT": "22" } | ||
| }, | ||
|
|
||
| // Team A specific minimal features | ||
| "features": { | ||
| "ghcr.io/devcontainers/features/github-cli:1": { | ||
| "version": "2.40.1" | ||
| } | ||
| }, | ||
|
|
||
| "customizations": { | ||
| "vscode": { | ||
| "settings": { | ||
| "terminal.integrated.shell.linux": "/bin/bash", | ||
| "cSpell.language": ",en", | ||
| "git.autofetch": false, | ||
| // Team A specific settings | ||
| "editor.formatOnSave": true, | ||
| "eslint.validate": ["javascript", "typescript", "markdown"] | ||
| }, | ||
| // Team A minimal essential extensions | ||
| "extensions": [ | ||
| "dbaeumer.vscode-eslint", | ||
| "sissel.shopify-liquid", | ||
| "davidanson.vscode-markdownlint", | ||
| "bierner.markdown-preview-github-styles" | ||
| ] | ||
| } | ||
| }, | ||
|
|
||
| "forwardPorts": [4000], | ||
|
|
||
| "portsAttributes": { | ||
| "4000": { | ||
| "label": "Team A Review" | ||
| } | ||
| }, | ||
|
|
||
| // Security-first approach - manual setup required | ||
| "onCreateCommand": "echo 'Team A secure container ready. Manual setup required for security.'", | ||
|
|
||
| "remoteUser": "node", | ||
|
|
||
| "hostRequirements": { | ||
| "memory": "8gb", | ||
| "cpus": "2" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| { | ||
| "name": "Team B Secure Codespace Config", | ||
| "build": { | ||
| "dockerfile": "../Dockerfile.hardened", | ||
| "args": { "VARIANT": "22" } | ||
| }, | ||
|
|
||
| // Team B specific minimal features - even more restrictive | ||
| "features": { | ||
| "ghcr.io/devcontainers/features/github-cli:1": { | ||
| "version": "2.40.1" | ||
| } | ||
| }, | ||
|
|
||
| "customizations": { | ||
| "vscode": { | ||
| "settings": { | ||
| "terminal.integrated.shell.linux": "/bin/bash", | ||
| "cSpell.language": ",en", | ||
| "git.autofetch": false, | ||
| // Team B ultra-secure settings | ||
| "editor.formatOnSave": false, | ||
| "git.confirmSync": true, | ||
| "security.workspace.trust.enabled": true | ||
| }, | ||
| // Team B ultra-minimal extensions | ||
| "extensions": [ | ||
| "dbaeumer.vscode-eslint", | ||
| "davidanson.vscode-markdownlint" | ||
| ] | ||
| } | ||
| }, | ||
|
|
||
| "forwardPorts": [4000], | ||
|
|
||
| "portsAttributes": { | ||
| "4000": { | ||
| "label": "Team B Review" | ||
| } | ||
| }, | ||
|
|
||
| // Maximum security - no automatic commands | ||
| // All setup must be done manually | ||
|
|
||
| "remoteUser": "node", | ||
|
|
||
| // Minimal resource allocation for security | ||
| "hostRequirements": { | ||
| "memory": "4gb", | ||
| "cpus": "2" | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.