Skip to content

Commit

Permalink
Merge pull request #51 from spiegel-im-spiegel/fix-bug-for-expire-days
Browse files Browse the repository at this point in the history
Fix bug of key expiration time in sub-packet 09
  • Loading branch information
spiegel-im-spiegel authored Sep 11, 2021
2 parents 3f9e4d1 + 42524a5 commit da29d5d
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
go-version: 1.17
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
Expand Down
7 changes: 1 addition & 6 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,13 @@ jobs:
# a pull request then we can checkout the head.
fetch-depth: 2

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: ^1.16
go-version: ^1.17
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
Expand All @@ -21,4 +21,4 @@ jobs:
# Optional: golangci-lint command line arguments.
args: --enable gosec
- name: testing
run: go test ./...
run: go test -shuffle on ./...
2 changes: 1 addition & 1 deletion .github/workflows/vulns.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: ^1.16
go-version: ^1.17
- name: install depm
run: go install github.com/spiegel-im-spiegel/depm@latest
- name: WriteGoList
Expand Down
6 changes: 3 additions & 3 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ tasks:
desc: Test and lint.
cmds:
- go mod verify
- go test ./...
- docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.41.1 golangci-lint run --enable gosec --timeout 3m0s ./...
- go test -shuffle on ./...
- docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.42.1 golangci-lint run --enable gosec --timeout 3m0s ./...
sources:
- ./go.mod
- '**/*.go'
Expand All @@ -37,7 +37,7 @@ tasks:
- rm -f ./go.sum
- go clean -cache
- go clean -modcache
- go mod tidy -v
- go mod tidy -v -go=1.17

graph:
desc: Make grapth of dependency modules.
Expand Down
Binary file modified dependency.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 10 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
module github.com/spiegel-im-spiegel/gpgpdump

go 1.16
go 1.17

require (
github.com/ProtonMail/go-crypto v0.0.0-20210707164159-52430bf6b52c
github.com/atotto/clipboard v0.1.4
github.com/spf13/cobra v1.2.1
github.com/spiegel-im-spiegel/errs v1.0.2
github.com/spiegel-im-spiegel/fetch v0.2.3
github.com/spiegel-im-spiegel/gocli v0.10.4
github.com/spiegel-im-spiegel/errs v1.0.5
github.com/spiegel-im-spiegel/fetch v0.2.5
github.com/spiegel-im-spiegel/gocli v0.10.5
)

require (
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 // indirect
)
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,12 @@ github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.8.1/go.mod h1:o0Pch8wJ9BVSWGQMbra6iw0oQ5oktSIBaujf1rJH9Ns=
github.com/spiegel-im-spiegel/errs v1.0.2 h1:v4amEwRDqRWjKHOILQnJSovYhZ4ZttEnBBXNXEzS6Sc=
github.com/spiegel-im-spiegel/errs v1.0.2/go.mod h1:UoasJYYujMcdkbT9USv8dfZWoMyaY3btqQxoLJImw0A=
github.com/spiegel-im-spiegel/fetch v0.2.3 h1:Zh5rHvOjfC81rxKvtUD21JT609smds+BRh+H84s8qEw=
github.com/spiegel-im-spiegel/fetch v0.2.3/go.mod h1:ePIXxdC9OvSarXEO6HW1MgQwtBaKQo0qgDLOhKFXkQ0=
github.com/spiegel-im-spiegel/gocli v0.10.4 h1:aoAWdiQ4hjNxmEod4EeTZTcjdCJcrNOwgHBs5BQYnEQ=
github.com/spiegel-im-spiegel/gocli v0.10.4/go.mod h1:ffI3zoggRyLOZ+IIgaVN8WVMUwfIwfvCEd/0Yl/PZ98=
github.com/spiegel-im-spiegel/errs v1.0.5 h1:5qAUEXPZgF4ZIUmw2vpe7OgDP0C8DIV67BKwjfLidJI=
github.com/spiegel-im-spiegel/errs v1.0.5/go.mod h1:mOsWcUc9hpRXjwdgJqJ3E2n6ibkYFvhNck1QD0ZVGOM=
github.com/spiegel-im-spiegel/fetch v0.2.5 h1:S3yMboi2AT8DqubEed3OQfRHLABK+R44ooEHNw5fqTk=
github.com/spiegel-im-spiegel/fetch v0.2.5/go.mod h1:1O8nwPhJvt5JGBwVPzngcT71Y65us4GCyjuVyvCN4sk=
github.com/spiegel-im-spiegel/gocli v0.10.5 h1:TBHnlJbkiuQuinMcQH1SzJMfvG+KhGTK2ahJm+x8/Rw=
github.com/spiegel-im-spiegel/gocli v0.10.5/go.mod h1:1T1zI2HJdDnw7oSP2nicaukG/ESTXoHp7/VPDyY/Df8=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
Expand Down
2 changes: 1 addition & 1 deletion parse/tags/sub09.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (s *sub09) Parse() (*result.Item, error) {
if err != nil {
return rootInfo, errs.New("illegal Key Expiration Time", errs.WithCause(err))
}
s.cxt.KeyCreationTime = nil
//s.cxt.KeyCreationTime = nil // never clear key creation time
return exp.ToItem(rootInfo.Name, s.cxt.Debug()), nil
}

Expand Down
1 change: 1 addition & 0 deletions parse/tags/tag05.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func newTag05(cxt *context.Context, tag values.TagID, body []byte) Tags {

// Parse parsing Secret-Key Packet
func (t *tag05) Parse() (*result.Item, error) {
t.cxt.KeyCreationTime = nil //clear key creation time
rootInfo := t.ToItem()
// [00] One-octet version number.
v, err := t.reader.ReadByte()
Expand Down
1 change: 1 addition & 0 deletions parse/tags/tag06.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func newTag06(cxt *context.Context, tag values.TagID, body []byte) Tags {

// Parse parsing Public-Key Packet
func (t *tag06) Parse() (*result.Item, error) {
t.cxt.KeyCreationTime = nil //clear key creation time
rootInfo := t.ToItem()
// [00] One-octet version number.
v, err := t.reader.ReadByte()
Expand Down
3 changes: 2 additions & 1 deletion parse/values/expire.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package values
import (
"encoding/binary"
"fmt"
"math"

"github.com/spiegel-im-spiegel/errs"
"github.com/spiegel-im-spiegel/gpgpdump/parse/reader"
Expand Down Expand Up @@ -37,7 +38,7 @@ func (e *Expire) ToItem(name string, dumpFlag bool) *result.Item {
}
return result.NewItem(
result.Name(name),
result.Value(fmt.Sprintf("%v days after", float64(exp)/86400.0)),
result.Value(fmt.Sprintf("%v days after", math.Ceil(float64(exp)/86400.0))),
result.Note(endDay),
result.DumpStr(DumpBytes(e.day, dumpFlag).String()),
)
Expand Down

0 comments on commit da29d5d

Please sign in to comment.