Skip to content

Commit 23b8ac0

Browse files
meysam81claudeCopilot
authored
feat: Implement DMARC report parser with Vue.js dashboard (#1)
* feat: Implement DMARC report parser with Vue.js dashboard This commit introduces a complete DMARC aggregate report parsing and visualization system, built as a single binary similar to listmonk. ## Backend (Go) - **IMAP Client**: Connects to email servers and fetches DMARC reports - TLS support for secure connections - Automatic decompression (gzip/zip) - Filters for DMARC report attachments - **RFC 7489 Compliant Parser**: Parses DMARC XML aggregate reports - Full schema support (metadata, policy, records) - DKIM and SPF authentication results - Policy evaluation and disposition tracking - **SQLite Storage**: Embedded database with no external dependencies - Report metadata and detailed records - Efficient indexing for queries - Statistics aggregation - **REST API**: Clean endpoints for dashboard data - /api/statistics - Overall compliance metrics - /api/reports - Paginated report listing - /api/reports/:id - Detailed report view - /api/top-sources - Top sending source IPs ## Frontend (Vue.js 3) - **Modern SPA Dashboard**: Responsive, delightful UI - Real-time statistics cards - Top sending sources with pass/fail visualization - Recent reports table with compliance badges - Detailed modal view for individual reports - Auto-refresh every 5 minutes - **Embedded in Binary**: Built frontend served from Go - Single binary deployment - No external static file server needed ## Features - Minimal dependencies (only Go stdlib + 3 packages) - Multiple operation modes (continuous, fetch-once, serve-only) - Configurable fetch intervals - Complete RFC 7489 compliance - Production-ready deployment options ## Infrastructure - Makefile for easy building - Dockerfile for containerized deployment - docker-compose.yml for quick start - Systemd service template - Comprehensive documentation ## Testing - Unit tests for parser - Manual API verification - End-to-end build validation Closes the initial implementation requirements for DMARC report parsing and visualization. * Update internal/config/config.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 7f1b2c9 commit 23b8ac0

File tree

24 files changed

+4149
-2
lines changed

24 files changed

+4149
-2
lines changed

.gitignore

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,27 @@ go.work.sum
2727
# env file
2828
.env
2929

30+
# Build artifacts
31+
bin/
32+
internal/api/dist/
33+
34+
# Database
35+
*.db
36+
37+
# Config files (sensitive)
38+
config.json
39+
40+
# Node.js
41+
node_modules/
42+
frontend/node_modules/
43+
frontend/dist/
44+
3045
# Editor/IDE
31-
# .idea/
32-
# .vscode/
46+
.idea/
47+
.vscode/
48+
*.swp
49+
*.swo
50+
51+
# OS
52+
.DS_Store
53+
Thumbs.db

CONTRIBUTING.md

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
# Contributing to Parse DMARC
2+
3+
Thank you for your interest in contributing to Parse DMARC! This document provides guidelines and instructions for contributing.
4+
5+
## Development Setup
6+
7+
### Prerequisites
8+
9+
- Go 1.21 or higher
10+
- Node.js 18+ and npm
11+
- Git
12+
13+
### Getting Started
14+
15+
1. Fork and clone the repository:
16+
```bash
17+
git clone https://github.com/meysam81/parse-dmarc.git
18+
cd parse-dmarc
19+
```
20+
21+
2. Install dependencies:
22+
```bash
23+
make install-deps
24+
```
25+
26+
3. Build the project:
27+
```bash
28+
make build
29+
```
30+
31+
## Project Structure
32+
33+
```
34+
parse-dmarc/
35+
├── cmd/parse-dmarc/ # Main application entry point
36+
├── internal/
37+
│ ├── api/ # REST API and web server
38+
│ ├── config/ # Configuration management
39+
│ ├── imap/ # IMAP client for fetching emails
40+
│ ├── parser/ # DMARC XML parser
41+
│ └── storage/ # SQLite database layer
42+
├── frontend/ # Vue.js 3 dashboard
43+
│ ├── src/
44+
│ │ ├── components/
45+
│ │ ├── views/
46+
│ │ └── App.vue
47+
│ └── package.json
48+
├── Makefile
49+
├── Dockerfile
50+
└── README.md
51+
```
52+
53+
## Development Workflow
54+
55+
### Backend Development
56+
57+
Run the application in development mode:
58+
```bash
59+
make dev
60+
```
61+
62+
Run tests:
63+
```bash
64+
go test ./...
65+
```
66+
67+
Add tests for new features in `*_test.go` files.
68+
69+
### Frontend Development
70+
71+
Start the frontend dev server with hot reload:
72+
```bash
73+
cd frontend
74+
npm run dev
75+
```
76+
77+
Build the frontend:
78+
```bash
79+
cd frontend
80+
npm run build
81+
```
82+
83+
### Making Changes
84+
85+
1. Create a new branch:
86+
```bash
87+
git checkout -b feature/your-feature-name
88+
```
89+
90+
2. Make your changes and commit:
91+
```bash
92+
git add .
93+
git commit -m "Description of changes"
94+
```
95+
96+
3. Push and create a pull request:
97+
```bash
98+
git push origin feature/your-feature-name
99+
```
100+
101+
## Code Style
102+
103+
### Go Code
104+
105+
- Follow standard Go formatting (`gofmt`)
106+
- Add comments for exported functions and types
107+
- Keep functions small and focused
108+
- Use meaningful variable names
109+
110+
### Vue.js Code
111+
112+
- Use Vue 3 Composition API
113+
- Follow Vue style guide
114+
- Keep components modular and reusable
115+
116+
## Testing
117+
118+
### Go Tests
119+
120+
Add tests for all new functionality:
121+
```bash
122+
go test -v ./...
123+
```
124+
125+
### Manual Testing
126+
127+
1. Generate a config file:
128+
```bash
129+
./bin/parse-dmarc -gen-config
130+
```
131+
132+
2. Edit config.json with test credentials
133+
134+
3. Run in serve-only mode for UI testing:
135+
```bash
136+
./bin/parse-dmarc -serve-only
137+
```
138+
139+
## Pull Request Guidelines
140+
141+
- Ensure all tests pass
142+
- Update documentation if needed
143+
- Keep PRs focused on a single feature/fix
144+
- Write clear commit messages
145+
- Reference any related issues
146+
147+
## Areas for Contribution
148+
149+
- **Forensic Reports**: Add support for DMARC forensic reports (RUF)
150+
- **OAuth2**: Implement OAuth2 for IMAP authentication
151+
- **Export**: Add CSV/JSON export functionality
152+
- **Alerts**: Email alerts for compliance issues
153+
- **Analytics**: Historical trend analysis
154+
- **Documentation**: Improve docs and examples
155+
- **Tests**: Increase test coverage
156+
157+
## Questions?
158+
159+
Open an issue for questions or discussions.
160+
161+
## License
162+
163+
By contributing, you agree that your contributions will be licensed under the MIT License.

Dockerfile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Build stage
2+
FROM node:18-alpine AS frontend-builder
3+
4+
WORKDIR /build/frontend
5+
COPY frontend/package*.json ./
6+
RUN npm install
7+
COPY frontend/ ./
8+
RUN npm run build
9+
10+
# Go build stage
11+
FROM golang:1.21-alpine AS backend-builder
12+
13+
RUN apk add --no-cache gcc musl-dev sqlite-dev
14+
15+
WORKDIR /build
16+
COPY go.mod go.sum ./
17+
RUN go mod download
18+
19+
COPY . .
20+
COPY --from=frontend-builder /build/internal/api/dist ./internal/api/dist
21+
22+
RUN go build -o parse-dmarc ./cmd/parse-dmarc
23+
24+
# Final stage
25+
FROM alpine:latest
26+
27+
RUN apk add --no-cache ca-certificates sqlite-libs
28+
29+
WORKDIR /app
30+
31+
COPY --from=backend-builder /build/parse-dmarc .
32+
33+
# Create directory for database
34+
RUN mkdir -p /data
35+
36+
# Expose port
37+
EXPOSE 8080
38+
39+
# Run the application
40+
ENTRYPOINT ["/app/parse-dmarc"]
41+
CMD ["-config=/data/config.json"]

Makefile

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
.PHONY: all build frontend backend clean install-deps run dev test
2+
3+
all: build
4+
5+
# Install all dependencies
6+
install-deps:
7+
@echo "Installing Go dependencies..."
8+
go mod tidy
9+
@echo "Installing Node.js dependencies..."
10+
cd frontend && npm install
11+
12+
# Build frontend
13+
frontend:
14+
@echo "Building frontend..."
15+
cd frontend && npm run build
16+
17+
# Build backend (with embedded frontend)
18+
backend: frontend
19+
@echo "Building Go binary..."
20+
go build -o bin/parse-dmarc ./cmd/parse-dmarc
21+
22+
# Full build
23+
build: frontend backend
24+
@echo "Build complete! Binary available at ./bin/parse-dmarc"
25+
26+
# Run in development mode
27+
dev:
28+
@echo "Starting development server..."
29+
go run ./cmd/parse-dmarc -config=config.json
30+
31+
# Generate sample config
32+
config:
33+
go run ./cmd/parse-dmarc -gen-config
34+
35+
# Clean build artifacts
36+
clean:
37+
@echo "Cleaning build artifacts..."
38+
rm -rf bin/
39+
rm -rf internal/api/dist/
40+
rm -rf frontend/node_modules/
41+
rm -f dmarc.db
42+
rm -f config.json
43+
44+
# Run tests
45+
test:
46+
go test -v ./...
47+
48+
# Install binary to system
49+
install: build
50+
@echo "Installing to /usr/local/bin..."
51+
sudo cp bin/parse-dmarc /usr/local/bin/
52+
53+
# Development frontend server
54+
frontend-dev:
55+
cd frontend && npm run dev

0 commit comments

Comments
 (0)