Skip to content

Commit

Permalink
Add support for VS Code's devcontainers + pre-commit (aircrack-ng#2220)
Browse files Browse the repository at this point in the history
This patch aims to make development a tad bit easier by providing
a complete development environment inside of VS Code.

Additionally, `pre-commit` is configured to ensure that source code
is properly formatted, prior to commit.

Signed-off-by: Joseph Benden <joe@benden.us>
  • Loading branch information
jbenden committed Jul 4, 2021
1 parent c6d57c4 commit 3e4e5b3
Show file tree
Hide file tree
Showing 11 changed files with 265 additions and 250 deletions.
25 changes: 25 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.154.2/containers/cpp/.devcontainer/base.Dockerfile

# [Choice] Debian / Ubuntu version: debian-10, debian-9, ubuntu-20.04, ubuntu-18.04
ARG VARIANT="buster"
FROM mcr.microsoft.com/vscode/devcontainers/cpp:0-${VARIANT}

ARG CLANGURL="https://releases.llvm.org/3.8.1/"
ARG CLANGFILE="clang+llvm-3.8.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz"

RUN apt-get update \
&& export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
build-essential autoconf automake libtool pkg-config libnl-3-dev libnl-genl-3-dev libssl-dev \
ethtool shtool rfkill zlib1g-dev libpcap-dev libsqlite3-dev libpcre3-dev libhwloc-dev \
libcmocka-dev hostapd wpasupplicant tcpdump screen iw usbutils expect gawk bear \
libtinfo5 \
clangd-10 \
clang-format-10 \
python3-pip \
&& rm -rf /var/lib/apt/lists/* \
&& /usr/bin/pip3 install pre-commit \
&& cd /tmp \
&& wget "${CLANGURL}/${CLANGFILE}" \
&& tar -x --strip-components=1 -C /usr/local -J -f ${CLANGFILE} \
&& rm -f ${CLANGFILE}
44 changes: 44 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// 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.154.2/containers/cpp
{
"name": "Aircrack-ng",
"build": {
"dockerfile": "Dockerfile",
// Update 'VARIANT' to pick an Debian / Ubuntu OS version: debian-10, debian-9, ubuntu-20.04, ubuntu-18.04
"args": {
"VARIANT": "ubuntu-20.04"
}
},
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined"
],
// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"editor.formatOnSave": true,
"clang-format.executable": "/usr/local/bin/clang-format",
"clang-format.fallbackStyle": "none",
"clang-format.assumeFilename": "${file}",
"clang-format.style": "file",
"editor.defaultFormatter": "llvm-vs-code-extensions.vscode-clangd",
"clangd.path": "/usr/bin/clangd-10",
"C_Cpp.clang_format_fallbackStyle": "none",
"C_Cpp.clang_format_path": "/usr/local/bin/clang-format",
"C_Cpp.clang_format_style": "file",
"C_Cpp.formatting": "clangFormat"
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-vscode.cpptools",
"xaver.clang-format",
"llvm-vs-code-extensions.vscode-clangd"
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "pre-commit install --install-hooks",
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
14 changes: 12 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ src/Makefile.in
!/build/m4/stubs/.gitkeep
/test/test-env.sh
/.idea
/.vscode
/.clang_complete
CMakeLists.txt
/cmake-build-*
Expand Down Expand Up @@ -108,4 +107,15 @@ coverage*.info
/include/aircrack-ng/version.h
/manpages/*.1
/manpages/*.8
*.pidb
/.ccls-cache
/.cache
/.gdb_history
/cscope*
/strace_out
/.clangd
/r*hs
/r*hs-bad
/r*tr
/r*tr-bad
*~
*.pidb
37 changes: 37 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
exclude: >
(?x)^(
.github/|AUTHORS|ChangeLog|INSTALLING|LICENSE|README|
appveyor.yml|build/airpcap.dll.def|contrib/|lib/csharp|
lib/radiotap|include/aircrack-ng/third-party|patches/|
test/|scripts/|manpages/|apparmor/
)
fail_fast: false

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
hooks:
- id: trailing-whitespace
exclude_types: [asm]
- id: check-added-large-files
- id: mixed-line-ending
exclude_types: [asm]
- id: check-byte-order-marker
- id: check-executables-have-shebangs
- id: check-merge-conflict

- repo: https://github.com/pocc/pre-commit-hooks
rev: python
hooks:
- id: clang-format
args: ["--version=3.8", "--style=file", "-i"]

- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.7.1.1
hooks:
- id: shellcheck
files: 'test/|scripts/|build/'
17 changes: 17 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/local/bin/clang",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64",
"compileCommands": "${workspaceFolder}/compile_commands.json"
}
],
"version": 4
}
32 changes: 32 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch aircrack-ng",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/.libs/aircrack-ng",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [
{
"name": "LD_LIBRARY_PATH",
"value": "${workspaceFolder}/.libs"
}
],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
59 changes: 59 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build Incremental",
"type": "shell",
"command": "make -j6 && make -j6 check",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": "$gcc",
"promptOnClose": false,
"presentation": {
"echo": true,
"reveal": "silent",
"focus": false,
"panel": "dedicated",
"showReuseMessage": false,
"clear": false
}
},{
"label": "Build Full",
"type": "shell",
"command": "autoreconf -vif && env CC=clang-10 CXX=clang++-10 CPP=clang-cpp-10 CFLAGS=\"-Og -g\" CXXFLAGS=\"-Og -g\" ./configure --enable-maintainer-mode --with-experimental --without-opt && bear make -j6 && bear -a make -j6 check",
"group": "build",
"problemMatcher": "$gcc",
"promptOnClose": false,
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "dedicated",
"showReuseMessage": false,
"clear": true
}
},{
"label": "Test",
"type": "shell",
"command": "make -j6 check",
"group":{
"kind": "test",
"isDefault": true
},
"problemMatcher": "$gcc",
"promptOnClose": false,
"presentation": {
"echo": true,
"reveal": "silent",
"focus": false,
"panel": "dedicated",
"showReuseMessage": false,
"clear": false
}
}
]
}
44 changes: 39 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ All tools are command line which allows for heavy scripting. A lot of GUIs have
* On Windows, if using clang, libiconv and libiconv-devel
* Linux: LibNetlink 1 or 3. It can be disabled by passing --disable-libnl to configure.
* pkg-config (pkgconf on FreeBSD)
* FreeBSD, OpenBSD, NetBSD, Solaris and OS X with macports: gmake
* FreeBSD, OpenBSD, NetBSD, Solaris and OS X with Macports: gmake
* Linux/Cygwin: make and Standard C++ Library development package (Debian: libstdc++-dev)

Note: Airmon-ng only requires pciutils if the system has a PCI/PCIe bus and it is populated.
Expand All @@ -47,12 +47,12 @@ Note: Airmon-ng only requires pciutils if the system has a PCI/PCIe bus and it i
## Optional stuff

* If you want SSID filtering with regular expression in airodump-ng
(-essid-regex) pcre development package is required.
(-essid-regex) PCRE development package is required.
* If you want to use airolib-ng and '-r' option in aircrack-ng,
SQLite development package >= 3.3.17 (3.6.X version or better is recommended)
* If you want to use Airpcap, the 'developer' directory from the CD/ISO/SDK is required.
* In order to build `besside-ng`, `besside-ng-crawler`, `easside-ng`, `tkiptun-ng` and `wesside-ng`,
libpcap development package is required (on Cygwin, use the Aircap SDK instead; see above)
libpcap development package is required (on Cygwin, use the Airpcap SDK instead; see above)
* rfkill
* If you want Airodump-ng to log GPS coordinates, gpsd is needed
* For best performance on SMP machines, ensure the hwloc library and headers are installed. It is strongly recommended on high core count systems, it may give a serious speed boost
Expand Down Expand Up @@ -380,6 +380,40 @@ to your choosing:
LD_LIBRARY_PATH=.libs gdb --args ./aircrack-ng [PARAMETERS]
```

# IDE development

## VS Code - devcontainers

A VS Code development environment is provided, as is, for rapid setup of a development environment. This additionally adds support for GitHub Codespaces.

### Requirements

The first requirement is a working [Docker Engine](https://docs.docker.com/engine/install/) environment.

Next, an installation of [VS Code](https://code.visualstudio.com/) with the following extension(s):

- [`Remote - Containers`](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) by Microsoft.

> The "Remote - Containers" extension will refuse to work with OSS Code.
### Usage

1. Clone this repository to your working folder:
```
$ git clone --recursive https://github.com/aircrack-ng/aircrack-ng.git
$ cd aircrack-ng
```
2. After cloning this repository, open the folder inside VS Code.
```
$ code .
```
> IMPORTANT: You should answer "Yes", if it asks if the folder should be opened inside a remote container. If it does not ask, then press `Ctrl+Shift+P` and type `open in container`. This should bring up the correct command, for which pressing enter will run said command.
3. A number of warnings might appear about a missing `compile_commands.json` file. These are safe to ignore for a moment, as this file is automatically generated after the initial compilation.
4. Now build the entire project by pressing `Ctrl+R` and selecting `Build Full` from the pop-up menu that appears.
5. VS Code should detect the `compile_commands.json` file and ask if it should be used; selecting "Yes, always" will complete the initial setup of a fully working IDE.
> IMPORTANT: If it doesn't detect the file, pressing `Ctrl+Shift+P` and typing `reload window` will bring up the selection to fully reload the environment.
6. At this point, nearly all features of VS Code will function; from Intellisense, auto-completion, live documentation, to code formatting. Additionally, there are pre-configured tasks for builds and tests, as well as an example GDB/LLDB configuration for debugging `aircrack-ng`.

# Packaging

Expand All @@ -392,7 +426,7 @@ the additional flag `--without-opt` to the `./configure` line:

`./configure --without-opt`

# Using precompiled binaries
# Using pre-compiled binaries

## Linux/BSD

Expand All @@ -405,7 +439,7 @@ We provide up to date versions via PackageCloud for a number of Linux distrubuti

## Windows
* Install the appropriate "monitor" driver for your card; standard drivers don't work for capturing data.
* Aircrack-ng suite is command line tools. So, you have to open a commandline
* Aircrack-ng suite is command line tools. So, you have to open a command-line
`Start menu -> Run... -> cmd.exe` then use them
* Run the executables without any parameters to have help

Expand Down
Loading

0 comments on commit 3e4e5b3

Please sign in to comment.