Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

version: 2
updates:
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

name: CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '1.23.6' ]
steps:
- uses: actions/checkout@v3

- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}

- name: Run CI
env:
COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
run: make ci
29 changes: 12 additions & 17 deletions .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
.tools/
bin/
vendor/
.idea/
.vscode/
coverage.txt
coverage.out
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.db
*.db-journal
*.mmdb
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work
go.work.sum

# env file
.env

build/
211 changes: 211 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@

run:
go: "1.22"
concurrency: 4
timeout: 5m
tests: false
issues-exit-code: 1
modules-download-mode: readonly

issues:
exclude-use-default: false
max-issues-per-linter: 100
max-same-issues: 4
new: false
exclude-files:
- ".+_test.go"
exclude-dirs:
- "vendor$"

output:
formats:
- format: line-number
sort-results: true

linters-settings:
govet:
check-shadowing: true
enable:
- asmdecl
- assign
- atomic
- atomicalign
- bools
- buildtag
- cgocall
- composites
- copylocks
- deepequalerrors
- errorsas
- findcall
- framepointer
- httpresponse
- ifaceassert
- loopclosure
- lostcancel
- nilfunc
- nilness
- printf
- reflectvaluecompare
- shadow
- shift
- sigchanyzer
- sortslice
- stdmethods
- stringintconv
- structtag
- testinggoroutine
- tests
- unmarshal
- unreachable
- unsafeptr
- unusedresult
- unusedwrite
disable:
- fieldalignment
gofmt:
simplify: true
errcheck:
check-type-assertions: true
check-blank: true
gocyclo:
min-complexity: 30
misspell:
locale: US
prealloc:
simple: true
range-loops: true
for-loops: true
unparam:
check-exported: false
gci:
skip-generated: true
custom-order: false
gosec:
includes:
- G101 # Look for hard coded credentials
- G102 # Bind to all interfaces
- G103 # Audit the use of unsafe block
- G104 # Audit errors not checked
- G106 # Audit the use of ssh.InsecureIgnoreHostKey
- G107 # Url provided to HTTP request as taint input
- G108 # Profiling endpoint automatically exposed on /debug/pprof
- G109 # Potential Integer overflow made by strconv.Atoi result conversion to int16/32
- G110 # Potential DoS vulnerability via decompression bomb
- G111 # Potential directory traversal
- G112 # Potential slowloris attack
- G113 # Usage of Rat.SetString in math/big with an overflow (CVE-2022-23772)
- G114 # Use of net/http serve function that has no support for setting timeouts
- G201 # SQL query construction using format string
- G202 # SQL query construction using string concatenation
- G203 # Use of unescaped data in HTML templates
- G204 # Audit use of command execution
- G301 # Poor file permissions used when creating a directory
- G302 # Poor file permissions used with chmod
- G303 # Creating tempfile using a predictable path
- G304 # File path provided as taint input
- G305 # File traversal when extracting zip/tar archive
- G306 # Poor file permissions used when writing to a new file
- G307 # Deferring a method which returns an error
- G401 # Detect the usage of DES, RC4, MD5 or SHA1
- G402 # Look for bad TLS connection settings
- G403 # Ensure minimum RSA key length of 2048 bits
- G404 # Insecure random number source (rand)
- G501 # Import blocklist: crypto/md5
- G502 # Import blocklist: crypto/des
- G503 # Import blocklist: crypto/rc4
- G504 # Import blocklist: net/http/cgi
- G505 # Import blocklist: crypto/sha1
- G601 # Implicit memory aliasing of items from a range statement
excludes:
- G101 # Look for hard coded credentials
- G102 # Bind to all interfaces
- G103 # Audit the use of unsafe block
- G104 # Audit errors not checked
- G106 # Audit the use of ssh.InsecureIgnoreHostKey
- G107 # Url provided to HTTP request as taint input
- G108 # Profiling endpoint automatically exposed on /debug/pprof
- G109 # Potential Integer overflow made by strconv.Atoi result conversion to int16/32
- G110 # Potential DoS vulnerability via decompression bomb
- G111 # Potential directory traversal
- G112 # Potential slowloris attack
- G113 # Usage of Rat.SetString in math/big with an overflow (CVE-2022-23772)
- G114 # Use of net/http serve function that has no support for setting timeouts
- G201 # SQL query construction using format string
- G202 # SQL query construction using string concatenation
- G203 # Use of unescaped data in HTML templates
- G204 # Audit use of command execution
- G301 # Poor file permissions used when creating a directory
- G302 # Poor file permissions used with chmod
- G303 # Creating tempfile using a predictable path
- G304 # File path provided as taint input
- G305 # File traversal when extracting zip/tar archive
- G306 # Poor file permissions used when writing to a new file
- G307 # Deferring a method which returns an error
- G401 # Detect the usage of DES, RC4, MD5 or SHA1
- G402 # Look for bad TLS connection settings
- G403 # Ensure minimum RSA key length of 2048 bits
- G404 # Insecure random number source (rand)
- G501 # Import blocklist: crypto/md5
- G502 # Import blocklist: crypto/des
- G503 # Import blocklist: crypto/rc4
- G504 # Import blocklist: net/http/cgi
- G505 # Import blocklist: crypto/sha1
- G601 # Implicit memory aliasing of items from a range statement
exclude-generated: true
severity: medium
confidence: medium
concurrency: 12
config:
global:
nosec: true
"#nosec": "#my-custom-nosec"
show-ignored: true
audit: true
G101:
pattern: "(?i)passwd|pass|password|pwd|secret|token|pw|apiKey|bearer|cred"
ignore_entropy: false
entropy_threshold: "80.0"
per_char_threshold: "3.0"
truncate: "32"
G104:
fmt:
- Fscanf
G111:
pattern: "http\\.Dir\\(\"\\/\"\\)|http\\.Dir\\('\\/'\\)"
G301: "0750"
G302: "0600"
G306: "0600"

lll:
line-length: 130
tab-width: 1
staticcheck:
go: "1.15"
# SAxxxx checks in https://staticcheck.io/docs/configuration/options/#checks
# Default: ["*"]
checks: [ "*", "-SA1019" ]

linters:
disable-all: true
enable:
- govet
- gofmt
- errcheck
- misspell
- gocyclo
- ineffassign
- goimports
- nakedret
- unparam
- unused
- prealloc
- durationcheck
- staticcheck
- makezero
- nilerr
- errorlint
- bodyclose
- gosec
- lll
fast: false
3 changes: 3 additions & 0 deletions .lic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
author: Mikhail Knyazhev <markus621@yandex.com>
lic_short: "BSD 3-Clause"
lic_file: LICENSE
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2025, The OSSPkg Team
Copyright (c) 2025, Mikhail Knyazhev <markus621@yandex.com>

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down
31 changes: 31 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

SHELL=/bin/bash


.PHONY: install
install:
go install go.osspkg.com/goppy/v2/cmd/goppy@latest
goppy setup-lib

.PHONY: lint
lint:
goppy lint

.PHONY: license
license:
goppy license

.PHONY: build
build:
goppy build --arch=amd64

.PHONY: tests
tests:
goppy test

.PHONY: pre-commit
pre-commit: install license lint tests build

.PHONY: ci
ci: pre-commit

3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module go.osspkg.com/gogen

go 1.23.6
Empty file added go.sum
Empty file.
39 changes: 39 additions & 0 deletions golang/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2025 Mikhail Knyazhev <markus621@yandex.com>. All rights reserved.
* Use of this source code is governed by a BSD 3-Clause license that can be found in the LICENSE file.
*/

package golang

import (
config2 "go.osspkg.com/gogen/internal/config"
)

var _ config2.Config = (*config)(nil)

type config struct{}

func (c config) OperationAvailable(op string) bool {
switch op {
case "+", "-", "*", "/", "%", "&", "|", "^", "<<", ">>", "&^", "+=", "-=", "*=", "/=", "%=",
"&=", "|=", "^=", "<<=", ">>=", "&^=", "&&", "||", "<-", "++", "--", "==", "<", ">", "=", "!", "~", "!=",
"<=", ">=", ":=", "...", "(", ")", "[", "]", "{", "}", ",", ".", ";", ":":
return true
default:
return false
}
}

func (config) CommentSingle() config2.OpenClose {
return config2.OpenClose{
Open: "//",
Close: "\n",
}
}

func (config) CommentMulti() config2.OpenClose {
return config2.OpenClose{
Open: "/*\n",
Close: "\n*/\n",
}
}
Loading
Loading