Skip to content

Commit

Permalink
Fix and improve recent additions
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaavi committed Aug 12, 2022
1 parent 663e8fc commit 3e3a8c2
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
8 changes: 4 additions & 4 deletions cmd/cmd-verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ var verifyCmd = &cobra.Command{
}

// Only verify if .sig or .letter.
if strings.HasSuffix(path, sigFileExtension) ||
if strings.HasSuffix(path, filesig.Extension) ||
strings.HasSuffix(path, letterFileExtension) {
if err := verify(path, true); err != nil {
verificationFails++
Expand Down Expand Up @@ -135,11 +135,11 @@ func verify(filename string, bulkMode bool) error {
signedBy, err = verifyLetter(filename, bulkMode)
case strings.HasSuffix(filename, letterFileExtension):
signedBy, err = verifyLetter(filename, bulkMode)
case strings.HasSuffix(filename, sigFileExtension):
filename = strings.TrimSuffix(filename, sigFileExtension)
case strings.HasSuffix(filename, filesig.Extension):
filename = strings.TrimSuffix(filename, filesig.Extension)
fallthrough
default:
signame = filename + sigFileExtension
signame = filename + filesig.Extension
signedBy, err = verifySig(filename, signame, bulkMode)
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func main() {
rootCmd.PersistentFlags().StringVarP(&trustStoreDir, "tsdir", "d", "",
"specify a truststore directory (default loaded from JESS_TS_DIR env variable)",
)
rootCmd.PersistentFlags().StringVarP(&trustStoreDir, "tskeyring", "k", "",
rootCmd.PersistentFlags().StringVarP(&trustStoreKeyring, "tskeyring", "r", "",
"specify a truststore keyring namespace (default loaded from JESS_TS_KEYRING env variable) - lower priority than tsdir",
)
rootCmd.PersistentFlags().StringVarP(&noSpec, "no", "n", "",
Expand Down
4 changes: 2 additions & 2 deletions envelope.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,14 +285,14 @@ func (e *Envelope) CleanSignets() {
}
}
for i, signet := range e.Senders {
e.Secrets[i] = &Signet{
e.Senders[i] = &Signet{
Version: signet.Version,
ID: signet.ID,
Scheme: signet.Scheme,
}
}
for i, signet := range e.Recipients {
e.Secrets[i] = &Signet{
e.Recipients[i] = &Signet{
Version: signet.Version,
ID: signet.ID,
Scheme: signet.Scheme,
Expand Down
3 changes: 3 additions & 0 deletions filesig/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import (
"github.com/safing/portbase/formats/dsd"
)

// Extension holds the default file extension to be used for signature files.
const Extension = ".sig"

var fileSigRequirements = jess.NewRequirements().
Remove(jess.RecipientAuthentication).
Remove(jess.Confidentiality)
Expand Down
6 changes: 4 additions & 2 deletions import_export.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,13 @@ func EnvelopeFromTextFormat(textFormat string) (*Envelope, error) {
return EnvelopeFromBase58(splitted[len(splitted)-1])
}

var replaceForTextFormatMatcher = regexp.MustCompile(`[^A-Za-z\-]+`)
var replaceForTextFormatMatcher = regexp.MustCompile(`[^A-Za-z0-9]+`)

// toTextFormatString makes a string compatible with the text format.
func toTextFormatString(s string) string {
return strings.ToLower(
replaceForTextFormatMatcher.ReplaceAllString(s, "_"),
strings.Trim(
replaceForTextFormatMatcher.ReplaceAllString(s, "-"), "-",
),
)
}

0 comments on commit 3e3a8c2

Please sign in to comment.