Skip to content

Commit

Permalink
This is the first commit, I promise
Browse files Browse the repository at this point in the history
  • Loading branch information
deponian committed May 12, 2024
0 parents commit 255ff9f
Show file tree
Hide file tree
Showing 57 changed files with 3,321 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning
name: CodeQL

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

permissions:
contents: read

jobs:
analyze:
permissions:
actions: read # for github/codeql-action/init to get workflow details
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/autobuild to send a status report
name: Analyze
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
language: ['go']

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: ./go.mod

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@v3

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
17 changes: 17 additions & 0 deletions .github/workflows/depsreview.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: 'Dependency Review'
on:
pull_request:
branches: [main]

permissions:
contents: read

jobs:
dependency-review:
name: Run dependency review
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v4
- name: 'Dependency Review'
uses: actions/dependency-review-action@v4
43 changes: 43 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
name: Tests

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

permissions:
contents: read

defaults:
run:
shell: bash

jobs:
test:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: ./go.mod

- name: Unit tests
run: |
mv .testdata src/builtins
go test -coverprofile=coverage.out ./src && go tool cover -func=coverage.out
- name: Check that we didn't lose anything
run: diff <(cat testlogs/* | go run ./main.go | sed 's/\x1b\[[0-9;]*m//g') <(cat testlogs/*)

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.3.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
15 changes: 15 additions & 0 deletions .github/workflows/typos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: "Spell Check"
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:

jobs:
typos:
name: Spell Check with Typos
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: crate-ci/typos@v1.20.1
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/
coverage.out
.logalize.yaml
38 changes: 38 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

version: 1

before:
hooks:
- go mod tidy

builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip

changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
3 changes: 3 additions & 0 deletions .testdata/logformats/bad.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
formats:
test:
pattern: bad:
43 changes: 43 additions & 0 deletions .testdata/logformats/good.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# $remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"
formats:
nginx-combined:
# $remote_addr
- pattern: (\d{1,3}(\.\d{1,3}){3} )
fg: "#f5ce42"
# -
- pattern: (- )
fg: "#807e7a"
# $remote_user
- pattern: ([^ ]+ )
fg: "#764a9e"
# [$time_local]
- pattern: (\[.+\] )
fg: "#148dd9"
# "$request"
- pattern: ("[^"]+" )
fg: "#9ddb56"
# $status
- pattern: (\d\d\d )
fg: "#ffffff"
alternatives:
- pattern: (2\d\d )
fg: "#00ff00"
style: bold
- pattern: (3\d\d )
fg: "#00ffff"
style: bold
- pattern: (4\d\d )
fg: "#ff0000"
style: bold
- pattern: (5\d\d )
fg: "#ff00ff"
style: bold
# $body_bytes_sent
- pattern: ([\d]+ )
fg: "#7d7d7d"
# "$http_referer"
- pattern: ("[^"]+" )
fg: "#3ae1f0"
# "$http_user_agent"
- pattern: ("[^"]+")
fg: "#aa7dd1"
2 changes: 2 additions & 0 deletions .testdata/words/bad.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
words:
bad: bad:
66 changes: 66 additions & 0 deletions .testdata/words/good.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
words:
good:
fg: "#52fa8a"
style: bold
list:
- "active"
- "attempt"
- "clean"
- "complete"
- "configure"
- "connect"
- "done"
- "enable"
- "finish"
- "found"
- "listen"
- "load"
- "ok"
- "online"
- "open"
- "ready"
- "register"
- "start"
- "succeed"
- "success"
- "successful"
- "successfully"
- "true"
- "valid"
bad:
fg: "#f06c62"
style: bold
list:
- "alarm"
- "block"
- "close"
- "critical"
- "deny"
- "disable"
- "down"
- "empty"
- "end"
- "error"
- "exit"
- "fail"
- "false"
- "fatal"
- "invalid"
- "offline"
- "shut"
- "stop"
- "terminate"
- "unable"
- "unreach"
warning:
fg: "#fcba03"
style: bold
list:
- "detected"
- "ignore"
- "miss"
- "readonly"
- "reload"
- "restart"
- "skip"
- "warn"
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Rufus Deponian

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
43 changes: 43 additions & 0 deletions builtins/logformats/nginx-combined.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# $remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"
formats:
nginx-combined:
# $remote_addr
- pattern: (\d{1,3}(\.\d{1,3}){3} )
fg: "#f5ce42"
# -
- pattern: (- )
fg: "#807e7a"
# $remote_user
- pattern: ([^ ]+ )
fg: "#764a9e"
# [$time_local]
- pattern: (\[.+\] )
fg: "#148dd9"
# "$request"
- pattern: ("[^"]+" )
fg: "#9ddb56"
# $status
- pattern: (\d\d\d )
fg: "#ffffff"
alternatives:
- pattern: (2\d\d )
fg: "#00ff00"
style: bold
- pattern: (3\d\d )
fg: "#00ffff"
style: bold
- pattern: (4\d\d )
fg: "#ff0000"
style: bold
- pattern: (5\d\d )
fg: "#ff00ff"
style: bold
# $body_bytes_sent
- pattern: ([\d]+ )
fg: "#7d7d7d"
# "$http_referer"
- pattern: ("[^"]+" )
fg: "#3ae1f0"
# "$http_user_agent"
- pattern: ("[^"]+")
fg: "#aa7dd1"
Loading

0 comments on commit 255ff9f

Please sign in to comment.