Skip to content

Commit

Permalink
Merge pull request #1 from logmanager-oss/feature/initial-implementation
Browse files Browse the repository at this point in the history
initial implementation
  • Loading branch information
tender-barbarian authored Jul 29, 2024
2 parents 6047d61 + dc80dab commit 6bd5952
Show file tree
Hide file tree
Showing 29 changed files with 5,512 additions and 1 deletion.
29 changes: 29 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: lint

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
run:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 'stable'
check-latest: true

- name: Lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
args: --timeout 5m
30 changes: 30 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: goreleaser

on:
push:
tags:
- "*"

permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: "~> v1"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: test

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
run:
name: Test
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.22.5
check-latest: true

- name: Checkout code
uses: actions/checkout@v4

- name: Run tests
run: go test -v -race ./...
31 changes: 31 additions & 0 deletions .github/workflows/vuln.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: vuln

on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: '0 10 * * 1' # run "At 10:00 on Monday"

jobs:
run:
name: Vuln
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 'stable'
check-latest: true

- name: Checkout
uses: actions/checkout@v4

- name: Install govulncheck
run: go install golang.org/x/vuln/cmd/govulncheck@latest

- name: Run govulncheck
run: govulncheck -test ./...
64 changes: 63 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,63 @@
# logveil
# logveil

## Description

Logveil is a simple CLI tool for log anonymizaiton. If you ever had a need to create a sample log data but were afraid to leak sensitive info this tool will help you make your logs anonymous.

## Usage

There are two components needed to make this work:

1. Your input log data in CSV format.
2. Anonymization data - which is data that will be used to replace original log data.

```
Usage of ./logveil:
-d value
Path to directory with anonymizing data
-i value
Path to input file containing logs to be anonymized
-o value
Path to output file containing anonymized logs
-v
Enable verbose logging
-h
Help for logveil
```

**Example:**

`./logveil -d example_anon_data/ -i test_log.csv -o output.txt`

### Input log data

Obviously first you need to provide log data to be anonymized. It needs to be in a CSV format. The columns in you CSV file will mark which values you want to anonymize.

As an example consider below log line. It is formatted in a standard `key:value` format. Key names mark the values.

```
{"@timestamp": "2024-06-05T14:59:27.000+00:00", "msg.src_ip":"89.239.31.49", "username":"[email protected]", "organization":"TESTuser.test.com"}
```

As such we can easily parse it into CSV file:

```
@timestamp,msg.src_ip,msg.username,msg.organization,raw
2024-06-05T14:59:27.000+00:00,89.239.31.49,[email protected],TESTuser.test.com,"{""@timestamp"": ""2024-06-05T14:59:27.000+00:00"", ""msg.src_ip"":""89.239.31.49"", ""username"":""[email protected]"", ""organization"":""TESTuser.test.com""}"
```

Now key names are simply column names in CSV file. `raw` contains original log line. When you run Logveil, column names will be matched against your anonymization data.

You can easily extract log data in such format from your Logmanager. Refer to Logmanager documentation for more info on how to Export data.

### Anonymization data

Each column for which you want to anonymize data must have its equivalent in anonymization data folder.

For example, if you want to anonymize values in `msg.src_ip` and `msg.username` columns, you need to have two files of the same name in anonymization folder.

### Output

Anonymized data will be outputted to provided file path in txt format (unparsed).

Alternatively, if you don't provide file path, output will be written to the console.
7 changes: 7 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "github.com/logmanager-oss/logveil/internal/anonymizer"

func main() {
anonymizer.Run()
}
9 changes: 9 additions & 0 deletions examples/anon_data/msg.dst_iface
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
wan1
lan1
lan2
dmz
if-servers
if-users
if-iot
External
Internal
Loading

0 comments on commit 6bd5952

Please sign in to comment.