mirror of
https://codeberg.org/scip/valpass.git
synced 2025-12-16 12:11:00 +01:00
move to codeberg (#1)
This commit is contained in:
47
.github/workflows/ci.yaml
vendored
47
.github/workflows/ci.yaml
vendored
@@ -1,47 +0,0 @@
|
|||||||
name: build-and-test
|
|
||||||
on: [push, pull_request]
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
version: ['1.22']
|
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
||||||
name: Build
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
steps:
|
|
||||||
- name: Set up Go
|
|
||||||
uses: actions/setup-go@v3
|
|
||||||
with:
|
|
||||||
go-version: '${{ matrix.version }}'
|
|
||||||
id: go
|
|
||||||
|
|
||||||
- name: checkout
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: build
|
|
||||||
run: go build
|
|
||||||
|
|
||||||
- name: test
|
|
||||||
run: make test
|
|
||||||
|
|
||||||
- name: Update coverage report
|
|
||||||
uses: ncruces/go-coverage-report@main
|
|
||||||
with:
|
|
||||||
report: true
|
|
||||||
chart: true
|
|
||||||
amend: true
|
|
||||||
if: |
|
|
||||||
matrix.os == 'ubuntu-latest' &&
|
|
||||||
github.event_name == 'push'
|
|
||||||
continue-on-error: true
|
|
||||||
|
|
||||||
golangci:
|
|
||||||
name: lint
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/setup-go@v3
|
|
||||||
with:
|
|
||||||
go-version: 1.22
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- name: golangci-lint
|
|
||||||
uses: golangci/golangci-lint-action@v3
|
|
||||||
65
.goreleaser.yaml
Normal file
65
.goreleaser.yaml
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
|
||||||
|
|
||||||
|
version: 2
|
||||||
|
|
||||||
|
before:
|
||||||
|
hooks:
|
||||||
|
- go mod tidy
|
||||||
|
|
||||||
|
gitea_urls:
|
||||||
|
api: https://codeberg.org/api/v1
|
||||||
|
download: https://codeberg.org
|
||||||
|
|
||||||
|
builds:
|
||||||
|
- env:
|
||||||
|
- CGO_ENABLED=0
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
- freebsd
|
||||||
|
|
||||||
|
archives:
|
||||||
|
- formats: [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 }}_{{ .Tag }}
|
||||||
|
# use zip for windows archives
|
||||||
|
format_overrides:
|
||||||
|
- goos: windows
|
||||||
|
formats: [zip]
|
||||||
|
- goos: linux
|
||||||
|
formats: [tar.gz,binary]
|
||||||
|
files:
|
||||||
|
- src: "*.md"
|
||||||
|
strip_parent: true
|
||||||
|
- src: Makefile.dist
|
||||||
|
dst: Makefile
|
||||||
|
wrap_in_directory: true
|
||||||
|
|
||||||
|
changelog:
|
||||||
|
sort: asc
|
||||||
|
filters:
|
||||||
|
exclude:
|
||||||
|
- "^docs:"
|
||||||
|
- "^test:"
|
||||||
|
groups:
|
||||||
|
- title: Improved
|
||||||
|
regexp: '^.*?(feat|add|new)(\([[:word:]]+\))??!?:.+$'
|
||||||
|
order: 0
|
||||||
|
- title: Fixed
|
||||||
|
regexp: '^.*?(bug|fix)(\([[:word:]]+\))??!?:.+$'
|
||||||
|
order: 1
|
||||||
|
- title: Changed
|
||||||
|
order: 999
|
||||||
|
|
||||||
|
release:
|
||||||
|
header: "# Release Notes"
|
||||||
|
footer: >-
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Full Changelog: [{{ .PreviousTag }}...{{ .Tag }}](https://codeberg.org/scip/valpass/compare/{{ .PreviousTag }}...{{ .Tag }})
|
||||||
36
.woodpecker/build.yaml
Normal file
36
.woodpecker/build.yaml
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
matrix:
|
||||||
|
platform:
|
||||||
|
- linux/amd64
|
||||||
|
goversion:
|
||||||
|
- 1.24
|
||||||
|
|
||||||
|
labels:
|
||||||
|
platform: ${platform}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
build:
|
||||||
|
when:
|
||||||
|
event: [push]
|
||||||
|
image: golang:${goversion}
|
||||||
|
commands:
|
||||||
|
- go get
|
||||||
|
- go build
|
||||||
|
|
||||||
|
linter:
|
||||||
|
when:
|
||||||
|
event: [push]
|
||||||
|
image: golang:${goversion}
|
||||||
|
commands:
|
||||||
|
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.5.0
|
||||||
|
- golangci-lint --version
|
||||||
|
- golangci-lint run ./...
|
||||||
|
depends_on: [build]
|
||||||
|
|
||||||
|
test:
|
||||||
|
when:
|
||||||
|
event: [push]
|
||||||
|
image: golang:${goversion}
|
||||||
|
commands:
|
||||||
|
- go get
|
||||||
|
- go test -v -cover
|
||||||
|
depends_on: [build,linter]
|
||||||
15
.woodpecker/release.yaml
Normal file
15
.woodpecker/release.yaml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# build release
|
||||||
|
|
||||||
|
labels:
|
||||||
|
platform: linux/amd64
|
||||||
|
|
||||||
|
steps:
|
||||||
|
goreleaser:
|
||||||
|
image: goreleaser/goreleaser
|
||||||
|
when:
|
||||||
|
event: [tag]
|
||||||
|
environment:
|
||||||
|
GITEA_TOKEN:
|
||||||
|
from_secret: DEPLOY_TOKEN
|
||||||
|
commands:
|
||||||
|
- goreleaser release --clean --verbose
|
||||||
18
Makefile.dist
Normal file
18
Makefile.dist
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# -*-make-*-
|
||||||
|
|
||||||
|
.PHONY: install all
|
||||||
|
|
||||||
|
tool = rpn
|
||||||
|
PREFIX = /usr/local
|
||||||
|
UID = root
|
||||||
|
GID = 0
|
||||||
|
|
||||||
|
all:
|
||||||
|
@echo "Type 'sudo make install' to install the tool."
|
||||||
|
@echo "To change prefix, type 'sudo make install PREFIX=/opt'"
|
||||||
|
|
||||||
|
install:
|
||||||
|
install -d -o $(UID) -g $(GID) $(PREFIX)/bin
|
||||||
|
install -d -o $(UID) -g $(GID) $(PREFIX)/share/doc
|
||||||
|
install -o $(UID) -g $(GID) -m 555 $(tool) $(PREFIX)/sbin/
|
||||||
|
install -o $(UID) -g $(GID) -m 444 *.md $(PREFIX)/share/doc/
|
||||||
27
README.md
27
README.md
@@ -1,8 +1,7 @@
|
|||||||
[](https://goreportcard.com/report/github.com/tlinden/valpass)
|
[](https://ci.codeberg.org/repos/15685)
|
||||||
[](https://github.com/tlinden/valpass/actions)
|
[](https://goreportcard.com/report/codeberg.org/scip/valpass)
|
||||||
[](https://raw.githack.com/wiki/tlinden/valpass/coverage.html)
|
[](https://codeberg.org/scip/valpass/raw/branch/main/LICENSE)
|
||||||

|
[](https://godoc.org/codeberg.org/scip/valpass)
|
||||||
[](https://godoc.org/github.com/tlinden/valpass)
|
|
||||||
|
|
||||||
# valpass - a small golang module to verify passwords
|
# valpass - a small golang module to verify passwords
|
||||||
|
|
||||||
@@ -13,7 +12,7 @@ just for fun and to learn more about cryptography.
|
|||||||
During development I wrote a little helper tool
|
During development I wrote a little helper tool
|
||||||
which I could use to verify some quality metrics
|
which I could use to verify some quality metrics
|
||||||
of my algorithm:
|
of my algorithm:
|
||||||
[analyze.c](https://github.com/TLINDEN/twenty4/blob/master/analyze/analyze.c).
|
[analyze.c](https://codeberg.org/scip/twenty4/blob/master/analyze/analyze.c).
|
||||||
|
|
||||||
This module is a re-implementation of this code
|
This module is a re-implementation of this code
|
||||||
with go as a reusable module.
|
with go as a reusable module.
|
||||||
@@ -108,10 +107,14 @@ you can tune the quality thresholds as needed.
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Usage is pretty simple:
|
Usage is pretty simple. First, import the module:
|
||||||
|
|
||||||
|
```default
|
||||||
|
go get codeberg.org/scip/valpass/v2
|
||||||
|
```
|
||||||
|
|
||||||
```go
|
```go
|
||||||
import "github.com/tlinden/valpass"
|
import "codeberg.org/scip/valpass/v2"
|
||||||
|
|
||||||
[..]
|
[..]
|
||||||
res, err := valpass.Validate("password"); if err != nil {
|
res, err := valpass.Validate("password"); if err != nil {
|
||||||
@@ -140,8 +143,8 @@ type Options struct {
|
|||||||
To turn off a test, just set the tunable to zero.
|
To turn off a test, just set the tunable to zero.
|
||||||
|
|
||||||
Please take a look at [the
|
Please take a look at [the
|
||||||
example](https://github.com/TLINDEN/valpass/blob/main/example/test.go)
|
example](https://codeberg.org/scip/valpass/raw/branch/main/example/test.go)
|
||||||
or at [the unit tests](https://github.com/TLINDEN/valpass/blob/main/lib_test.go).
|
or at [the unit tests](https://codeberg.org/scip/valpass/raw/branch/main/lib_test.go).
|
||||||
|
|
||||||
## Performance
|
## Performance
|
||||||
|
|
||||||
@@ -151,7 +154,7 @@ Benchmark results of version 0.0.1:
|
|||||||
% go test -bench=. -count 5
|
% go test -bench=. -count 5
|
||||||
goos: linux
|
goos: linux
|
||||||
goarch: amd64
|
goarch: amd64
|
||||||
pkg: github.com/tlinden/valpass
|
pkg: codeberg.org/scip/valpass
|
||||||
cpu: Intel(R) Core(TM) i7-10610U CPU @ 1.80GHz
|
cpu: Intel(R) Core(TM) i7-10610U CPU @ 1.80GHz
|
||||||
BenchmarkValidateEntropy-8 98703 12402 ns/op
|
BenchmarkValidateEntropy-8 98703 12402 ns/op
|
||||||
BenchmarkValidateEntropy-8 92745 12258 ns/op
|
BenchmarkValidateEntropy-8 92745 12258 ns/op
|
||||||
@@ -184,7 +187,7 @@ BenchmarkValidateAllwDict-8 404 3022698 ns/op
|
|||||||
BenchmarkValidateAllwDict-8 393 3075163 ns/op
|
BenchmarkValidateAllwDict-8 393 3075163 ns/op
|
||||||
BenchmarkValidateAllwDict-8 381 3112361 ns/op
|
BenchmarkValidateAllwDict-8 381 3112361 ns/op
|
||||||
PASS
|
PASS
|
||||||
ok github.com/tlinden/valpass 54.017s
|
ok codeberg.org/scip/valpass 54.017s
|
||||||
```
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/tlinden/valpass"
|
"codeberg.org/scip/valpass/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
const template string = `
|
const template string = `
|
||||||
@@ -58,7 +58,11 @@ func ReadDict(path string) []string {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer func() {
|
||||||
|
if err := file.Close(); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
var lines []string
|
var lines []string
|
||||||
scanner := bufio.NewScanner(file)
|
scanner := bufio.NewScanner(file)
|
||||||
|
|||||||
4
go.mod
4
go.mod
@@ -1,5 +1,5 @@
|
|||||||
module github.com/tlinden/valpass
|
module codeberg.org/scip/valpass/v2
|
||||||
|
|
||||||
go 1.22
|
go 1.24
|
||||||
|
|
||||||
require github.com/alecthomas/repr v0.4.0 // indirect
|
require github.com/alecthomas/repr v0.4.0 // indirect
|
||||||
|
|||||||
@@ -3,12 +3,13 @@ package valpass_test
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/tlinden/valpass"
|
"codeberg.org/scip/valpass/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Passwordlist [][]string
|
type Passwordlist [][]string
|
||||||
@@ -372,7 +373,11 @@ func ReadDict(path string) []string {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer func() {
|
||||||
|
if err := file.Close(); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
var lines []string
|
var lines []string
|
||||||
scanner := bufio.NewScanner(file)
|
scanner := bufio.NewScanner(file)
|
||||||
|
|||||||
Reference in New Issue
Block a user