Skip to content

Commit 936a3bf

Browse files
authored
add bitmap + refactoring bloom filter and base62 (#25)
* add bitmap + refactoring bloom filter and base62
1 parent a278173 commit 936a3bf

File tree

10 files changed

+559
-332
lines changed

10 files changed

+559
-332
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:
15-
go: [ '1.22.11' ]
15+
go: [ '1.23.11' ]
1616
steps:
1717
- uses: actions/checkout@v3
1818

.github/workflows/codeql.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

.golangci.yml

Lines changed: 37 additions & 181 deletions
Original file line numberDiff line numberDiff line change
@@ -1,202 +1,61 @@
1+
version: "2"
12

23
run:
3-
go: "1.22"
4-
concurrency: 4
4+
go: "1.23"
55
timeout: 5m
66
tests: false
77
issues-exit-code: 1
88
modules-download-mode: readonly
9+
allow-parallel-runners: true
910

1011
issues:
11-
exclude-use-default: false
12-
max-issues-per-linter: 100
13-
max-same-issues: 4
12+
max-issues-per-linter: 0
13+
max-same-issues: 0
1414
new: false
15-
exclude-files:
16-
- ".+_test.go"
17-
exclude-dirs:
18-
- "vendor$"
15+
fix: false
1916

2017
output:
2118
formats:
22-
- format: line-number
23-
sort-results: true
19+
text:
20+
print-linter-name: true
21+
print-issued-lines: true
2422

25-
linters-settings:
26-
govet:
27-
check-shadowing: true
28-
enable:
29-
- asmdecl
30-
- assign
31-
- atomic
32-
- atomicalign
33-
- bools
34-
- buildtag
35-
- cgocall
36-
- composites
37-
- copylocks
38-
- deepequalerrors
39-
- errorsas
40-
- findcall
41-
- framepointer
42-
- httpresponse
43-
- ifaceassert
44-
- loopclosure
45-
- lostcancel
46-
- nilfunc
47-
- nilness
48-
- printf
49-
- reflectvaluecompare
50-
- shadow
51-
- shift
52-
- sigchanyzer
53-
- sortslice
54-
- stdmethods
55-
- stringintconv
56-
- structtag
57-
- testinggoroutine
58-
- tests
59-
- unmarshal
60-
- unreachable
61-
- unsafeptr
62-
- unusedresult
63-
- unusedwrite
64-
disable:
65-
- fieldalignment
66-
gofmt:
67-
simplify: true
68-
errcheck:
69-
check-type-assertions: true
70-
check-blank: true
71-
gocyclo:
72-
min-complexity: 30
73-
misspell:
74-
locale: US
75-
prealloc:
76-
simple: true
77-
range-loops: true
78-
for-loops: true
79-
unparam:
80-
check-exported: false
81-
gci:
82-
skip-generated: true
83-
custom-order: false
84-
gosec:
85-
includes:
86-
- G101 # Look for hard coded credentials
87-
- G102 # Bind to all interfaces
88-
- G103 # Audit the use of unsafe block
89-
- G104 # Audit errors not checked
90-
- G106 # Audit the use of ssh.InsecureIgnoreHostKey
91-
- G107 # Url provided to HTTP request as taint input
92-
- G108 # Profiling endpoint automatically exposed on /debug/pprof
93-
- G109 # Potential Integer overflow made by strconv.Atoi result conversion to int16/32
94-
- G110 # Potential DoS vulnerability via decompression bomb
95-
- G111 # Potential directory traversal
96-
- G112 # Potential slowloris attack
97-
- G113 # Usage of Rat.SetString in math/big with an overflow (CVE-2022-23772)
98-
- G114 # Use of net/http serve function that has no support for setting timeouts
99-
- G201 # SQL query construction using format string
100-
- G202 # SQL query construction using string concatenation
101-
- G203 # Use of unescaped data in HTML templates
102-
- G204 # Audit use of command execution
103-
- G301 # Poor file permissions used when creating a directory
104-
- G302 # Poor file permissions used with chmod
105-
- G303 # Creating tempfile using a predictable path
106-
- G304 # File path provided as taint input
107-
- G305 # File traversal when extracting zip/tar archive
108-
- G306 # Poor file permissions used when writing to a new file
109-
- G307 # Deferring a method which returns an error
110-
- G401 # Detect the usage of DES, RC4, MD5 or SHA1
111-
- G402 # Look for bad TLS connection settings
112-
- G403 # Ensure minimum RSA key length of 2048 bits
113-
- G404 # Insecure random number source (rand)
114-
- G501 # Import blocklist: crypto/md5
115-
- G502 # Import blocklist: crypto/des
116-
- G503 # Import blocklist: crypto/rc4
117-
- G504 # Import blocklist: net/http/cgi
118-
- G505 # Import blocklist: crypto/sha1
119-
- G601 # Implicit memory aliasing of items from a range statement
120-
excludes:
121-
- G101 # Look for hard coded credentials
122-
- G102 # Bind to all interfaces
123-
- G103 # Audit the use of unsafe block
124-
- G104 # Audit errors not checked
125-
- G106 # Audit the use of ssh.InsecureIgnoreHostKey
126-
- G107 # Url provided to HTTP request as taint input
127-
- G108 # Profiling endpoint automatically exposed on /debug/pprof
128-
- G109 # Potential Integer overflow made by strconv.Atoi result conversion to int16/32
129-
- G110 # Potential DoS vulnerability via decompression bomb
130-
- G111 # Potential directory traversal
131-
- G112 # Potential slowloris attack
132-
- G113 # Usage of Rat.SetString in math/big with an overflow (CVE-2022-23772)
133-
- G114 # Use of net/http serve function that has no support for setting timeouts
134-
- G201 # SQL query construction using format string
135-
- G202 # SQL query construction using string concatenation
136-
- G203 # Use of unescaped data in HTML templates
137-
- G204 # Audit use of command execution
138-
- G301 # Poor file permissions used when creating a directory
139-
- G302 # Poor file permissions used with chmod
140-
- G303 # Creating tempfile using a predictable path
141-
- G304 # File path provided as taint input
142-
- G305 # File traversal when extracting zip/tar archive
143-
- G306 # Poor file permissions used when writing to a new file
144-
- G307 # Deferring a method which returns an error
145-
- G401 # Detect the usage of DES, RC4, MD5 or SHA1
146-
- G402 # Look for bad TLS connection settings
147-
- G403 # Ensure minimum RSA key length of 2048 bits
148-
- G404 # Insecure random number source (rand)
149-
- G501 # Import blocklist: crypto/md5
150-
- G502 # Import blocklist: crypto/des
151-
- G503 # Import blocklist: crypto/rc4
152-
- G504 # Import blocklist: net/http/cgi
153-
- G505 # Import blocklist: crypto/sha1
154-
- G601 # Implicit memory aliasing of items from a range statement
155-
exclude-generated: true
156-
severity: medium
157-
confidence: medium
158-
concurrency: 12
159-
config:
160-
global:
161-
nosec: true
162-
"#nosec": "#my-custom-nosec"
163-
show-ignored: true
164-
audit: true
165-
G101:
166-
pattern: "(?i)passwd|pass|password|pwd|secret|token|pw|apiKey|bearer|cred"
167-
ignore_entropy: false
168-
entropy_threshold: "80.0"
169-
per_char_threshold: "3.0"
170-
truncate: "32"
171-
G104:
172-
fmt:
173-
- Fscanf
174-
G111:
175-
pattern: "http\\.Dir\\(\"\\/\"\\)|http\\.Dir\\('\\/'\\)"
176-
G301: "0750"
177-
G302: "0600"
178-
G306: "0600"
179-
180-
lll:
181-
line-length: 130
182-
tab-width: 1
183-
staticcheck:
184-
go: "1.15"
185-
# SAxxxx checks in https://staticcheck.io/docs/configuration/options/#checks
186-
# Default: ["*"]
187-
checks: [ "*", "-SA1019" ]
23+
formatters:
24+
exclusions:
25+
paths:
26+
- vendors/
27+
enable:
28+
- gofmt
29+
- goimports
18830

18931
linters:
190-
disable-all: true
32+
settings:
33+
staticcheck:
34+
checks:
35+
- all
36+
- -S1023
37+
- -ST1000
38+
- -ST1003
39+
- -ST1020
40+
gosec:
41+
excludes:
42+
- G104
43+
- G115
44+
- G301
45+
- G304
46+
- G306
47+
- G501
48+
- G505
49+
exclusions:
50+
paths:
51+
- vendors/
52+
default: none
19153
enable:
19254
- govet
193-
- gofmt
19455
- errcheck
19556
- misspell
19657
- gocyclo
19758
- ineffassign
198-
- goimports
199-
- nakedret
20059
- unparam
20160
- unused
20261
- prealloc
@@ -206,7 +65,4 @@ linters:
20665
- nilerr
20766
- errorlint
20867
- bodyclose
209-
- exportloopref
21068
- gosec
211-
- lll
212-
fast: false

encoding/base62/base62.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55

66
package base62
77

8-
import "go.osspkg.com/algorithms/sorts"
8+
import (
9+
"bytes"
10+
11+
"go.osspkg.com/algorithms/sorts"
12+
)
913

1014
const size = 62
1115

@@ -40,8 +44,8 @@ func (v *Base62) Encode(id uint64) string {
4044

4145
func (v *Base62) Decode(data string) uint64 {
4246
var id uint64
43-
for _, b := range []byte(data) {
44-
id = id*size + v.dec[b]
47+
for _, r := range data {
48+
id = id*size + uint64(bytes.IndexRune(v.enc, r))
4549
}
4650
return id
4751
}

0 commit comments

Comments
 (0)