mirror of
https://github.com/SSLMate/certspotter.git
synced 2025-07-01 10:35:33 +02:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
b649b399e4 | ||
![]() |
aecfa745ca | ||
![]() |
f5779c283c | ||
![]() |
3e811e86d7 | ||
![]() |
a4048f47f8 | ||
![]() |
187aed078c |
35
.github/workflows/test.yml
vendored
Normal file
35
.github/workflows/test.yml
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
name: Test and lint Go Code
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
schedule:
|
||||||
|
- cron: '42 9 * * *' # Runs daily at 09:42 UTC
|
||||||
|
workflow_dispatch: # Allows manual triggering
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
name: Test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: CGO_ENABLED=1 go test -race ./...
|
||||||
|
|
||||||
|
- name: Install staticcheck
|
||||||
|
run: go install honnef.co/go/tools/cmd/staticcheck@latest
|
||||||
|
|
||||||
|
- name: Run staticcheck
|
||||||
|
run: staticcheck ./...
|
4
asn1.go
4
asn1.go
@ -46,7 +46,7 @@ func decodeASN1String(value *asn1.RawValue) (string, error) {
|
|||||||
if value.Tag == 12 {
|
if value.Tag == 12 {
|
||||||
// UTF8String
|
// UTF8String
|
||||||
if !utf8.Valid(value.Bytes) {
|
if !utf8.Valid(value.Bytes) {
|
||||||
return "", errors.New("Malformed UTF8String")
|
return "", errors.New("malformed UTF8String")
|
||||||
}
|
}
|
||||||
return string(value.Bytes), nil
|
return string(value.Bytes), nil
|
||||||
} else if value.Tag == 19 || value.Tag == 22 || value.Tag == 20 || value.Tag == 26 {
|
} else if value.Tag == 19 || value.Tag == 22 || value.Tag == 20 || value.Tag == 26 {
|
||||||
@ -74,5 +74,5 @@ func decodeASN1String(value *asn1.RawValue) (string, error) {
|
|||||||
return stringFromUint32Slice(runes), nil
|
return stringFromUint32Slice(runes), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "", errors.New("Not a string")
|
return "", errors.New("not a string")
|
||||||
}
|
}
|
||||||
|
@ -253,5 +253,5 @@ func decodeASN1Time(value *asn1.RawValue) (time.Time, error) {
|
|||||||
return parseGeneralizedTime(value.Bytes)
|
return parseGeneralizedTime(value.Bytes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return time.Time{}, errors.New("Not a time value")
|
return time.Time{}, errors.New("not a time value")
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"software.sslmate.com/src/certspotter/ctclient"
|
||||||
"software.sslmate.com/src/certspotter/loglist"
|
"software.sslmate.com/src/certspotter/loglist"
|
||||||
"software.sslmate.com/src/certspotter/monitor"
|
"software.sslmate.com/src/certspotter/monitor"
|
||||||
)
|
)
|
||||||
@ -139,6 +140,7 @@ func appendFunc(slice *[]string) func(string) error {
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
loglist.UserAgent = fmt.Sprintf("certspotter/%s (%s; %s; %s)", certspotterVersion(), runtime.Version(), runtime.GOOS, runtime.GOARCH)
|
loglist.UserAgent = fmt.Sprintf("certspotter/%s (%s; %s; %s)", certspotterVersion(), runtime.Version(), runtime.GOOS, runtime.GOARCH)
|
||||||
|
ctclient.UserAgent = fmt.Sprintf("certspotter/%s (+https://github.com/SSLMate/certspotter)", certspotterVersion())
|
||||||
|
|
||||||
var flags struct {
|
var flags struct {
|
||||||
batchSize bool
|
batchSize bool
|
||||||
|
@ -24,6 +24,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var UserAgent = "software.sslmate.com/src/certspotter"
|
||||||
|
|
||||||
// Create an HTTP client suitable for communicating with CT logs. dialContext, if non-nil, is used for dialing.
|
// Create an HTTP client suitable for communicating with CT logs. dialContext, if non-nil, is used for dialing.
|
||||||
func NewHTTPClient(dialContext func(context.Context, string, string) (net.Conn, error)) *http.Client {
|
func NewHTTPClient(dialContext func(context.Context, string, string) (net.Conn, error)) *http.Client {
|
||||||
return &http.Client{
|
return &http.Client{
|
||||||
@ -61,7 +63,7 @@ func get(ctx context.Context, httpClient *http.Client, fullURL string) ([]byte,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
request.Header.Set("User-Agent", "") // Don't send a User-Agent to make life harder for malicious logs
|
request.Header.Set("User-Agent", UserAgent)
|
||||||
|
|
||||||
if httpClient == nil {
|
if httpClient == nil {
|
||||||
httpClient = defaultHTTPClient
|
httpClient = defaultHTTPClient
|
||||||
|
@ -21,7 +21,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var UserAgent = "certspotter"
|
var UserAgent = "software.sslmate.com/src/certspotter"
|
||||||
|
|
||||||
type ModificationToken struct {
|
type ModificationToken struct {
|
||||||
etag string
|
etag string
|
||||||
@ -112,7 +112,7 @@ func Unmarshal(jsonBytes []byte) (*List, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if err := list.Validate(); err != nil {
|
if err := list.Validate(); err != nil {
|
||||||
return nil, fmt.Errorf("Invalid log list: %s", err)
|
return nil, fmt.Errorf("invalid log list: %s", err)
|
||||||
}
|
}
|
||||||
return list, nil
|
return list, nil
|
||||||
}
|
}
|
||||||
|
@ -206,7 +206,7 @@ func newLogClient(config *Config, ctlog *loglist.Log) (ctclient.Log, ctclient.Is
|
|||||||
logGetter: client,
|
logGetter: client,
|
||||||
}, nil
|
}, nil
|
||||||
default:
|
default:
|
||||||
return nil, nil, fmt.Errorf("log uses unknown protocol")
|
return nil, nil, errors.New("log uses unknown protocol")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ func sendEmail(ctx context.Context, to []string, notif *notification) error {
|
|||||||
if err := sendmail.Run(); err == nil || err == exec.ErrWaitDelay {
|
if err := sendmail.Run(); err == nil || err == exec.ErrWaitDelay {
|
||||||
return nil
|
return nil
|
||||||
} else if sendmailCtx.Err() != nil && ctx.Err() == nil {
|
} else if sendmailCtx.Err() != nil && ctx.Err() == nil {
|
||||||
return fmt.Errorf("error sending email to %v: sendmail command timed out")
|
return fmt.Errorf("error sending email to %v: sendmail command timed out", to)
|
||||||
} else if ctx.Err() != nil {
|
} else if ctx.Err() != nil {
|
||||||
// if the context was canceled, we can't be sure that the error is the fault of sendmail, so ignore it
|
// if the context was canceled, we can't be sure that the error is the fault of sendmail, so ignore it
|
||||||
return ctx.Err()
|
return ctx.Err()
|
||||||
|
1
staticcheck.conf
Normal file
1
staticcheck.conf
Normal file
@ -0,0 +1 @@
|
|||||||
|
checks = ["inherit", "-ST1005", "-S1002"]
|
Loading…
x
Reference in New Issue
Block a user