Skip to content

Commit 2045751

Browse files
authored
Merge pull request #6 from breml/add-goreleaser
Add goreleaser
2 parents 0761294 + 81fdf48 commit 2045751

File tree

4 files changed

+105
-1
lines changed

4 files changed

+105
-1
lines changed

.github/workflows/release.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: goreleaser
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]*'
7+
8+
jobs:
9+
goreleaser:
10+
runs-on: ubuntu-latest
11+
steps:
12+
-
13+
name: Checkout
14+
uses: actions/checkout@v2
15+
with:
16+
fetch-depth: 0
17+
18+
-
19+
name: Set up Go
20+
uses: actions/setup-go@v2
21+
with:
22+
go-version: 1.16
23+
24+
-
25+
name: Run GoReleaser
26+
uses: goreleaser/goreleaser-action@v2
27+
with:
28+
distribution: goreleaser
29+
version: latest
30+
args: release --rm-dist
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This is an example .goreleaser.yml file with some sane defaults.
2+
# Make sure to check the documentation at http://goreleaser.com
3+
before:
4+
hooks:
5+
# You may remove this if you don't use go modules.
6+
- go mod tidy
7+
builds:
8+
- main: ./cmd/bidichk
9+
binary: bidichk
10+
env:
11+
- CGO_ENABLED=0
12+
goos:
13+
- linux
14+
- windows
15+
- darwin
16+
archives:
17+
- name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
18+
replacements:
19+
darwin: Darwin
20+
linux: Linux
21+
windows: Windows
22+
386: i386
23+
amd64: x86_64
24+
snapshot:
25+
name_template: "{{ .Tag }}-next"
26+
changelog:
27+
skip: true
28+
release:
29+
github:
30+
owner: breml
31+
name: bidichk

README.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# bidichk - checks for dangerous unicode character sequences
22

3-
[![Test Status](https://github.com/breml/bidichk/workflows/Go%20Matrix/badge.svg)](https://github.com/breml/logstash-config/actions?query=workflow%3AGo%20Matrix) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
3+
[![Test Status](https://github.com/breml/bidichk/workflows/Go%20Matrix/badge.svg)](https://github.com/breml/bidichk/actions?query=workflow%3AGo%20Matrix) [![Go Report Card](https://goreportcard.com/badge/github.com/breml/bidichk)](https://goreportcard.com/report/github.com/breml/bidichk) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
44

55
bidichk finds dangerous unicode character sequences in Go source files.
66

@@ -18,6 +18,46 @@ The following unicode characters are considered dangerous:
1818
* U+2068: FIRST-STRONG-ISOLATE
1919
* U+2069: POP-DIRECTIONAL-ISOLATE
2020

21+
## Installation
22+
23+
Download `bidichk` from the [releases](https://github.com/breml/bidichk/releases) or get the latest version from source with:
24+
25+
```shell
26+
go get github.com/breml/bidichk/cmd/bidichk
27+
```
28+
29+
## Usage
30+
31+
### golangci-lint
32+
33+
[golangci-lint](https://golangci-lint.run) supports thelper, so you can enable this linter and use it.
34+
35+
### Shell
36+
37+
Check everything:
38+
39+
```shell
40+
bidichk ./...
41+
```
42+
43+
### Enable only required unicode runes
44+
45+
If you run bidichk via golangci-lint look at [.golangci.example.yml](https://golangci-lint.run/usage/configuration/#config-file) for an example of the configuration.
46+
47+
Otherwise you can run bidichk with `--disallowed-runes` flag to specify the runes you consider harmful.
48+
49+
E.g. the following command considers only the `LEFT-TO-RIGHT-OVERRIDE` unicode rune as dangerous:
50+
51+
```shell
52+
bidichk --disallowed-runes LEFT-TO-RIGHT-OVERRIDE ./...
53+
```
54+
55+
For the full list of supported unicode runes [see above](#considered-dangerous-unicode-characters) or use
56+
57+
```shell
58+
bidichk --help
59+
```
60+
2161
## Inspiration
2262

2363
* ['Trojan Source' Bug Threatens the Security of All Code](https://krebsonsecurity.com/2021/11/trojan-source-bug-threatens-the-security-of-all-code/)

pkg/bidichk/bidichk.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ type bidichk struct {
120120
disallowedRunes disallowedRunes
121121
}
122122

123+
// NewAnalyzer return a new bidichk analyzer.
123124
func NewAnalyzer() *analysis.Analyzer {
124125
bidichk := bidichk{}
125126
bidichk.disallowedRunes = make(map[string]rune, len(runeLookup))

0 commit comments

Comments
 (0)