diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 5f5aea83c..89737d57f 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,18 +1,64 @@ { - "name": "pwndbg", - "build": { - "context": "..", - "dockerfile": "../Dockerfile" - }, - "runArgs": [ - "--security-opt=no-new-privileges:true", - "--cap-drop=ALL", - "--cap-add=SYS_PTRACE" - ], - "workspaceFolder": "/pwndbg", - "workspaceMount": "source=${localWorkspaceFolder},target=/pwndbg,type=bind,consistency=cached", - "settings": {}, - "extensions": [ - "ms-python.python" - ] -} \ No newline at end of file + "name": "pwndbg", + "build": { + "args": {}, + "context": "..", + "dockerfile": "../Dockerfile" + }, + "features": {}, + "customizations": { + "vscode": { + "settings": { + "docker.languageserver.formatter.ignoreMultilineInstructions": true, + "editor.bracketPairColorization.enabled": true, + "editor.fontWeight": "bold", + "editor.formatOnSave": true, + "editor.guides.bracketPairs": "active", + "editor.guides.bracketPairsHorizontal": "active", + "editor.guides.highlightActiveBracketPair": true, + "editor.guides.highlightActiveIndentation": true, + "editor.guides.indentation": true, + "editor.renderWhitespace": "all", + "files.exclude": { + "**/.git/**": true, + "**/.mypy_cache/**": true, + "**/__pycache__/**": true + }, + "files.watcherExclude": { + "**/.git/**": true, + "**/.mypy_cache/**": true, + "**/.venv/**": true, + "**/__pycache__/**": true + }, + "python.analysis.diagnosticMode": "workspace", + "python.analysis.typeCheckingMode": "strict", + "python.languageServer": "Pylance", + "python.linting.pylintUseMinimalCheckers": false, + "python.venvPath": "/venv", + "[python]": { + "editor.defaultFormatter": "ms-python.black-formatter", + "editor.codeActionsOnSave": { + "source.organizeImports": true + }, + "editor.formatOnType": true + } + }, + "extensions": [ + "charliermarsh.ruff", + "ms-azuretools.vscode-docker", + "ms-python.black-formatter", + "ms-python.isort", + "ms-python.mypy-type-checker", + "ms-python.pylint", + "ms-python.python", + "ms-python.vscode-pylance" + ] + } + }, + "runArgs": [ + "--cap-add=SYS_PTRACE" + ], + "remoteUser": "vscode", + "workspaceFolder": "/pwndbg", + "workspaceMount": "source=${localWorkspaceFolder},target=/pwndbg,type=bind,consistency=cached" +} diff --git a/Dockerfile b/Dockerfile index 97b782f3b..81610acea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ # docker run -it --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -v `pwd`:/pwndbg pwndbg bash # -ARG image=ubuntu:20.04 +ARG image=mcr.microsoft.com/devcontainers/base:jammy FROM $image WORKDIR /pwndbg @@ -44,6 +44,13 @@ RUN rm README.md && rm -rf pwndbg ADD ./setup-dev.sh /pwndbg/ RUN ./setup-dev.sh -RUN echo "source /pwndbg/gdbinit.py" >> ~/.gdbinit.py - ADD . /pwndbg/ + +ARG LOW_PRIVILEGE_USER="vscode" + +# Add .gdbinit to the home folder of both root and vscode users (if vscode user exists) +# This is useful for a VSCode dev container, not really for test builds +RUN if [ ! -f ~/.gdbinit ]; then echo "source /pwndbg/gdbinit.py" >> ~/.gdbinit; fi && \ + if id -u ${LOW_PRIVILEGE_USER} > /dev/null 2>&1; then \ + su ${LOW_PRIVILEGE_USER} -c 'if [ ! -f ~/.gdbinit ]; then echo "source /pwndbg/gdbinit.py" >> ~/.gdbinit; fi'; \ + fi