mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 11:08:10 +00:00
Remove spurious fmt.Printf calls including one of a key (#15344)
And add a semgrep for fmt.Printf/Println.
This commit is contained in:
committed by
GitHub
parent
cbdf16c5a1
commit
38b0fa6b53
@@ -198,7 +198,6 @@ func (a *AzureAuth) getJWT() (string, error) {
|
|||||||
func getMetadata() (metadataJSON, error) {
|
func getMetadata() (metadataJSON, error) {
|
||||||
metadataEndpoint, err := url.Parse(fmt.Sprintf("%s/metadata/instance", metadataEndpoint))
|
metadataEndpoint, err := url.Parse(fmt.Sprintf("%s/metadata/instance", metadataEndpoint))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error creating URL: ", err)
|
|
||||||
return metadataJSON{}, err
|
return metadataJSON{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ func (eci encryptedContentInfo) decrypt(key []byte) ([]byte, error) {
|
|||||||
!alg.Equal(OIDEncryptionAlgorithmAES128CBC) &&
|
!alg.Equal(OIDEncryptionAlgorithmAES128CBC) &&
|
||||||
!alg.Equal(OIDEncryptionAlgorithmAES128GCM) &&
|
!alg.Equal(OIDEncryptionAlgorithmAES128GCM) &&
|
||||||
!alg.Equal(OIDEncryptionAlgorithmAES256GCM) {
|
!alg.Equal(OIDEncryptionAlgorithmAES256GCM) {
|
||||||
fmt.Printf("Unsupported Content Encryption Algorithm: %s\n", alg)
|
|
||||||
return nil, ErrUnsupportedAlgorithm
|
return nil, ErrUnsupportedAlgorithm
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ package pkcs7
|
|||||||
import (
|
import (
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"encoding/pem"
|
"encoding/pem"
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
@@ -108,7 +107,7 @@ but that's not what ships are built for.
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
fmt.Printf("%s\n", pemSignature)
|
t.Logf("%s\n", pemSignature)
|
||||||
derBlock, _ := pem.Decode(pemSignature)
|
derBlock, _ := pem.Decode(pemSignature)
|
||||||
if derBlock == nil {
|
if derBlock == nil {
|
||||||
t.Fatalf("failed to read DER block from signature PEM %s", tmpSignedFile.Name())
|
t.Fatalf("failed to read DER block from signature PEM %s", tmpSignedFile.Name())
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ func (b *backend) pathCredsRead(ctx context.Context, req *logical.Request, d *fr
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to generate username: %w", err)
|
return nil, fmt.Errorf("failed to generate username: %w", err)
|
||||||
}
|
}
|
||||||
fmt.Printf("username: %s\n", username)
|
|
||||||
|
|
||||||
password, err := b.generatePassword(ctx, config.PasswordPolicy)
|
password, err := b.generatePassword(ctx, config.PasswordPolicy)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -320,7 +320,6 @@ func testParseEntropy(t *testing.T, oss bool) {
|
|||||||
case err != test.outErr:
|
case err != test.outErr:
|
||||||
t.Fatalf("error mismatch: expected %#v got %#v", err, test.outErr)
|
t.Fatalf("error mismatch: expected %#v got %#v", err, test.outErr)
|
||||||
case err == nil && config.Entropy != nil && *config.Entropy != test.outEntropy:
|
case err == nil && config.Entropy != nil && *config.Entropy != test.outEntropy:
|
||||||
fmt.Printf("\n config.Entropy: %#v", config.Entropy)
|
|
||||||
t.Fatalf("entropy config mismatch: expected %#v got %#v", test.outEntropy, *config.Entropy)
|
t.Fatalf("entropy config mismatch: expected %#v got %#v", test.outEntropy, *config.Entropy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import (
|
|||||||
"crypto/cipher"
|
"crypto/cipher"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/hex"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@@ -90,7 +89,6 @@ func DeriveSharedKey(secret, ourPublic, theirPublic []byte) ([]byte, error) {
|
|||||||
if n != 32 {
|
if n != 32 {
|
||||||
return nil, errors.New("short read from hkdf")
|
return nil, errors.New("short read from hkdf")
|
||||||
}
|
}
|
||||||
fmt.Printf("Key: %s\n", hex.EncodeToString(key[:]))
|
|
||||||
|
|
||||||
return key[:], nil
|
return key[:], nil
|
||||||
}
|
}
|
||||||
|
|||||||
16
tools/semgrep/ci/fmt-printf.yml
Normal file
16
tools/semgrep/ci/fmt-printf.yml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
rules:
|
||||||
|
- id: fmt.Printf
|
||||||
|
languages: [go]
|
||||||
|
message: fmt.Printf/Println is forbidden outside of cmd and test files
|
||||||
|
patterns:
|
||||||
|
- pattern-either:
|
||||||
|
- pattern: fmt.Printf
|
||||||
|
- pattern: fmt.Println
|
||||||
|
severity: ERROR
|
||||||
|
paths:
|
||||||
|
exclude:
|
||||||
|
- "*_test.go"
|
||||||
|
- "cmd/*.go"
|
||||||
|
- "cmd/**/*.go"
|
||||||
|
- sdk/database/dbplugin/server.go # effectively a cmd
|
||||||
|
- sdk/database/dbplugin/v5/plugin_server.go # effectively a cmd
|
||||||
Reference in New Issue
Block a user