move logsecretfilter into packer sdk

This commit is contained in:
Megan Marsh 2020-11-19 14:03:11 -08:00
parent 14bdb9516c
commit a6fdeca099
45 changed files with 74 additions and 96 deletions

View File

@ -77,7 +77,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
return nil, nil, errs
}
packer.LogSecretFilter.Set(b.config.AlicloudAccessKey, b.config.AlicloudSecretKey)
packersdk.LogSecretFilter.Set(b.config.AlicloudAccessKey, b.config.AlicloudSecretKey)
return nil, nil, nil
}

View File

@ -339,7 +339,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
return nil, warns, errs
}
packer.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)
packersdk.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)
generatedData := awscommon.GetGeneratedDataList()
generatedData = append(generatedData, "Device", "MountPath")

View File

@ -13,7 +13,6 @@ import (
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/retry"
@ -92,7 +91,7 @@ WaitLoop:
}
// store so that we can access this later during provisioning
state.Put("winrm_password", s.Comm.WinRMPassword)
packer.LogSecretFilter.Set(s.Comm.WinRMPassword)
packersdk.LogSecretFilter.Set(s.Comm.WinRMPassword)
return multistep.ActionContinue
}

View File

@ -145,7 +145,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
return nil, warns, errs
}
packer.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)
packersdk.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)
generatedData := awscommon.GetGeneratedDataList()
return generatedData, warns, nil

View File

@ -168,7 +168,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
return nil, warns, errs
}
packer.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)
packersdk.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)
generatedData := awscommon.GetGeneratedDataList()
return generatedData, warns, nil

View File

@ -159,7 +159,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
return nil, warns, errs
}
packer.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)
packersdk.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)
generatedData := awscommon.GetGeneratedDataList()
return generatedData, warns, nil

View File

@ -228,7 +228,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
if errs != nil && len(errs.Errors) > 0 {
return nil, warns, errs
}
packer.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)
packersdk.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)
generatedData := awscommon.GetGeneratedDataList()
return generatedData, warns, nil

View File

@ -29,7 +29,6 @@ import (
"github.com/hashicorp/packer/builder/azure/common/constants"
"github.com/hashicorp/packer/builder/azure/pkcs12"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
@ -690,7 +689,7 @@ func setRuntimeValues(c *Config) {
c.tmpAdminPassword = tempName.AdminPassword
// store so that we can access this later during provisioning
packer.LogSecretFilter.Set(c.tmpAdminPassword)
packersdk.LogSecretFilter.Set(c.tmpAdminPassword)
c.tmpCertificatePassword = tempName.CertificatePassword
if c.TempComputeName == "" {

View File

@ -359,7 +359,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
return nil, warns, errs
}
packer.LogSecretFilter.Set(b.config.ClientConfig.ClientSecret, b.config.ClientConfig.ClientJWT)
packersdk.LogSecretFilter.Set(b.config.ClientConfig.ClientSecret, b.config.ClientConfig.ClientJWT)
return nil, warns, nil
}

View File

@ -25,7 +25,6 @@ import (
"github.com/hashicorp/packer/builder/azure/pkcs12"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
@ -492,7 +491,7 @@ func setRuntimeValues(c *Config) {
var tempName = NewTempName(c)
c.tmpAdminPassword = tempName.AdminPassword
packer.LogSecretFilter.Set(c.tmpAdminPassword)
packersdk.LogSecretFilter.Set(c.tmpAdminPassword)
c.tmpCertificatePassword = tempName.CertificatePassword
c.tmpComputeName = tempName.ComputeName

View File

@ -3,8 +3,8 @@ package dtl
import (
"context"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
type StepSaveWinRMPassword struct {
@ -15,7 +15,7 @@ type StepSaveWinRMPassword struct {
func (s *StepSaveWinRMPassword) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
// store so that we can access this later during provisioning
state.Put("winrm_password", s.Password)
packer.LogSecretFilter.Set(s.Password)
packersdk.LogSecretFilter.Set(s.Password)
return multistep.ActionContinue
}

View File

@ -11,7 +11,6 @@ import (
"time"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
@ -214,6 +213,6 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
return nil, errs
}
packer.LogSecretFilter.Set(c.APIToken)
packersdk.LogSecretFilter.Set(c.APIToken)
return nil, nil
}

View File

@ -13,7 +13,6 @@ import (
"os"
"time"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
@ -33,7 +32,7 @@ func (s *StepCreateWindowsPassword) Run(ctx context.Context, state multistep.Sta
if c.Comm.WinRMPassword != "" {
state.Put("winrm_password", c.Comm.WinRMPassword)
packer.LogSecretFilter.Set(c.Comm.WinRMPassword)
packersdk.LogSecretFilter.Set(c.Comm.WinRMPassword)
return multistep.ActionContinue
}
@ -119,7 +118,7 @@ func (s *StepCreateWindowsPassword) Run(ctx context.Context, state multistep.Sta
}
state.Put("winrm_password", data.password)
packer.LogSecretFilter.Set(data.password)
packersdk.LogSecretFilter.Set(data.password)
return multistep.ActionContinue
}

View File

@ -9,7 +9,6 @@ import (
"time"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
@ -144,7 +143,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
return nil, errs
}
packer.LogSecretFilter.Set(c.HCloudToken)
packersdk.LogSecretFilter.Set(c.HCloudToken)
return nil, nil
}

View File

@ -11,7 +11,6 @@ import (
"time"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
"github.com/hashicorp/packer/packer-plugin-sdk/json"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
@ -308,7 +307,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
return nil, errs
}
packer.LogSecretFilter.Set(c.Token)
packersdk.LogSecretFilter.Set(c.Token)
return nil, nil
}

View File

@ -38,7 +38,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
return nil, nil, errs
}
packer.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey)
packersdk.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey)
return nil, nil, nil
}

View File

@ -12,7 +12,6 @@ import (
"time"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
@ -144,6 +143,6 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
return nil, errs
}
packer.LogSecretFilter.Set(c.PersonalAccessToken)
packersdk.LogSecretFilter.Set(c.PersonalAccessToken)
return nil, nil
}

View File

@ -9,7 +9,6 @@ import (
"github.com/1and1/oneandone-cloudserver-sdk-go"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
@ -109,6 +108,6 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
if errs != nil && len(errs.Errors) > 0 {
return nil, errs
}
packer.LogSecretFilter.Set(c.Token)
packersdk.LogSecretFilter.Set(c.Token)
return nil, nil
}

View File

@ -69,7 +69,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
b.config.InstanceName = b.config.ImageName
}
packer.LogSecretFilter.Set(b.config.Password)
packersdk.LogSecretFilter.Set(b.config.Password)
return nil, nil, nil
}

View File

@ -9,7 +9,6 @@ import (
"github.com/gophercloud/gophercloud/openstack/compute/v2/servers"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"golang.org/x/crypto/ssh"
@ -78,7 +77,7 @@ func (s *StepGetPassword) Run(ctx context.Context, state multistep.StateBag) mul
"Password (since debug is enabled) \"%s\"", s.Comm.WinRMPassword))
}
packer.LogSecretFilter.Set(s.Comm.WinRMPassword)
packersdk.LogSecretFilter.Set(s.Comm.WinRMPassword)
return multistep.ActionContinue
}

View File

@ -6,7 +6,6 @@ import (
"log"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
@ -53,7 +52,7 @@ func (s *stepGetDefaultCredentials) Run(ctx context.Context, state multistep.Sta
// store so that we can access this later during provisioning
state.Put("winrm_password", s.Comm.WinRMPassword)
packer.LogSecretFilter.Set(s.Comm.WinRMPassword)
packersdk.LogSecretFilter.Set(s.Comm.WinRMPassword)
return multistep.ActionContinue
}

View File

@ -81,7 +81,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
return nil, nil, errs
}
packer.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)
packersdk.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)
return nil, nil, nil
}

View File

@ -98,7 +98,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
return nil, nil, errs
}
packer.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)
packersdk.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)
return nil, nil, nil
}

View File

@ -84,7 +84,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
return nil, nil, errs
}
packer.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)
packersdk.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)
return nil, nil, nil
}

View File

@ -184,7 +184,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
return nil, warns, errs
}
packer.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)
packersdk.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)
return nil, warns, nil
}

View File

@ -13,7 +13,6 @@ import (
"github.com/antihax/optional"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/outscale/osc-sdk-go/osc"
@ -96,7 +95,7 @@ WaitLoop:
"Password (since debug is enabled): %s", s.Comm.WinRMPassword))
}
// store so that we can access this later during provisioning
packer.LogSecretFilter.Set(s.Comm.WinRMPassword)
packersdk.LogSecretFilter.Set(s.Comm.WinRMPassword)
return multistep.ActionContinue
}

View File

@ -7,7 +7,6 @@ import (
"os"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
@ -123,7 +122,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
if errs != nil && len(errs.Errors) > 0 {
return nil, errs
}
packer.LogSecretFilter.Set(c.PBUsername)
packersdk.LogSecretFilter.Set(c.PBUsername)
return nil, nil
}

View File

@ -12,7 +12,6 @@ import (
"time"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/bootcommand"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps"
@ -123,7 +122,7 @@ func (c *Config) Prepare(upper interface{}, raws ...interface{}) ([]string, []st
var errs *packersdk.MultiError
var warnings []string
packer.LogSecretFilter.Set(c.Password)
packersdk.LogSecretFilter.Set(c.Password)
// Defaults
if c.ProxmoxURLRaw == "" {

View File

@ -11,7 +11,6 @@ import (
"github.com/hashicorp/packer/builder/scaleway/version"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
@ -260,7 +259,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
return warnings, errs
}
packer.LogSecretFilter.Set(c.Token)
packer.LogSecretFilter.Set(c.SecretKey)
packersdk.LogSecretFilter.Set(c.Token)
packersdk.LogSecretFilter.Set(c.SecretKey)
return warnings, nil
}

View File

@ -60,7 +60,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
return nil, nil, errs
}
packer.LogSecretFilter.Set(b.config.SecretId, b.config.SecretKey)
packersdk.LogSecretFilter.Set(b.config.SecretId, b.config.SecretKey)
return nil, nil, nil
}

View File

@ -64,7 +64,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
return nil, nil, errs
}
packer.LogSecretFilter.Set(b.config.PublicKey, b.config.PrivateKey)
packersdk.LogSecretFilter.Set(b.config.PublicKey, b.config.PrivateKey)
return nil, nil, nil
}

View File

@ -7,7 +7,7 @@ import (
"fmt"
"os"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
"github.com/yandex-cloud/go-sdk/iamkey"
)
@ -52,7 +52,7 @@ func (c *AccessConfig) Prepare(ctx *interpolate.Context) []error {
}
if c.Token != "" {
packer.LogSecretFilter.Set(c.Token)
packersdk.LogSecretFilter.Set(c.Token)
}
if c.ServiceAccountKeyFile != "" {

View File

@ -10,6 +10,7 @@ import (
"github.com/hashicorp/hcl/v2/ext/dynblock"
"github.com/hashicorp/hcl/v2/hclparse"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/zclconf/go-cty/cty"
)
@ -260,7 +261,7 @@ func (cfg *PackerConfig) Initialize() hcl.Diagnostics {
value, _ := variable.Value()
_ = cty.Walk(value, func(_ cty.Path, nested cty.Value) (bool, error) {
if nested.IsWhollyKnown() && !nested.IsNull() && nested.Type().Equals(cty.String) {
packer.LogSecretFilter.Set(nested.AsString())
packersdk.LogSecretFilter.Set(nested.AsString())
}
return true, nil
})

View File

@ -65,7 +65,7 @@ func realMain() int {
logWriter = ioutil.Discard
}
packer.LogSecretFilter.SetOutput(logWriter)
packersdk.LogSecretFilter.SetOutput(logWriter)
// Disable logging here
log.SetOutput(ioutil.Discard)
@ -99,7 +99,7 @@ func realMain() int {
// Create the configuration for panicwrap and wrap our executable
wrapConfig.Handler = panicHandler(logTempFile)
wrapConfig.Writer = io.MultiWriter(logTempFile, &packer.LogSecretFilter)
wrapConfig.Writer = io.MultiWriter(logTempFile, &packersdk.LogSecretFilter)
wrapConfig.Stdout = outW
wrapConfig.DetectDuration = 500 * time.Millisecond
wrapConfig.ForwardSignals = []os.Signal{syscall.SIGTERM}
@ -135,8 +135,8 @@ func wrappedMain() int {
runtime.GOMAXPROCS(runtime.NumCPU())
}
packer.LogSecretFilter.SetOutput(os.Stderr)
log.SetOutput(&packer.LogSecretFilter)
packersdk.LogSecretFilter.SetOutput(os.Stderr)
log.SetOutput(&packersdk.LogSecretFilter)
inPlugin := inPlugin()
if inPlugin {

View File

@ -3,6 +3,7 @@ package packer
import (
"bytes"
"io"
"strings"
"sync"
)
@ -35,6 +36,17 @@ func (l *secretFilter) Write(p []byte) (n int, err error) {
return l.w.Write(p)
}
// FilterString will overwrite any senstitive variables in a string, returning
// the filtered string.
func (l *secretFilter) FilterString(message string) string {
for s := range l.s {
if s != "" {
message = strings.Replace(message, s, "<sensitive>", -1)
}
}
return message
}
func (l *secretFilter) get() (s []string) {
l.m.Lock()
defer l.m.Unlock()

View File

@ -10,7 +10,6 @@ import (
"sync"
"syscall"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/iochan"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
@ -26,7 +25,7 @@ func RunAndStream(cmd *exec.Cmd, ui packersdk.Ui, sensitive []string) error {
defer stderr_w.Close()
// Scrub any sensitive values from being printed to Packer ui.
packer.LogSecretFilter.Set(sensitive...)
packersdk.LogSecretFilter.Set(sensitive...)
args := make([]string, len(cmd.Args)-1)
copy(args, cmd.Args[1:])

View File

@ -15,6 +15,7 @@ import (
multierror "github.com/hashicorp/go-multierror"
version "github.com/hashicorp/go-version"
"github.com/hashicorp/hcl/v2"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
)
@ -113,7 +114,7 @@ func (core *Core) Initialize() error {
return err
}
for _, secret := range core.secrets {
LogSecretFilter.Set(secret)
packersdk.LogSecretFilter.Set(secret)
}
// Go through and interpolate all the build names. We should be able

View File

@ -8,6 +8,7 @@ import (
"reflect"
"testing"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template"
configHelper "github.com/hashicorp/packer/packer-plugin-sdk/template/config"
)
@ -679,13 +680,13 @@ func TestSensitiveVars(t *testing.T) {
if (err != nil) != tc.Err {
t.Fatalf("err: %s\n\n%s", tc.File, err)
}
filtered := LogSecretFilter.get()
filtered := packersdk.LogSecretFilter.get()
if filtered[0] != tc.Expected && len(filtered) != 1 {
t.Fatalf("not filtering sensitive vars; filtered is %#v", filtered)
}
// clear filter so it doesn't break other tests
LogSecretFilter.s = make(map[string]struct{})
packersdk.LogSecretFilter.s = make(map[string]struct{})
}
}

View File

@ -237,12 +237,8 @@ func (rw *BasicUi) Say(message string) {
rw.l.Lock()
defer rw.l.Unlock()
// Use LogSecretFilter to scrub out sensitive variables
for s := range LogSecretFilter.s {
if s != "" {
message = strings.Replace(message, s, "<sensitive>", -1)
}
}
// Use packersdk.LogSecretFilter to scrub out sensitive variables
message = packersdk.LogSecretFilter.FilterString(message)
log.Printf("ui: %s", message)
_, err := fmt.Fprint(rw.Writer, message+"\n")
@ -255,12 +251,8 @@ func (rw *BasicUi) Message(message string) {
rw.l.Lock()
defer rw.l.Unlock()
// Use LogSecretFilter to scrub out sensitive variables
for s := range LogSecretFilter.s {
if s != "" {
message = strings.Replace(message, s, "<sensitive>", -1)
}
}
// Use packersdk.LogSecretFilter to scrub out sensitive variables
message = packersdk.LogSecretFilter.FilterString(message)
log.Printf("ui: %s", message)
_, err := fmt.Fprint(rw.Writer, message+"\n")
@ -278,12 +270,8 @@ func (rw *BasicUi) Error(message string) {
writer = rw.Writer
}
// Use LogSecretFilter to scrub out sensitive variables
for s := range LogSecretFilter.s {
if s != "" {
message = strings.Replace(message, s, "<sensitive>", -1)
}
}
// Use packersdk.LogSecretFilter to scrub out sensitive variables
message = packersdk.LogSecretFilter.FilterString(message)
log.Printf("ui error: %s", message)
_, err := fmt.Fprint(writer, message+"\n")
@ -338,12 +326,8 @@ func (u *MachineReadableUi) Machine(category string, args ...string) {
// Prepare the args
for i, v := range args {
// Use LogSecretFilter to scrub out sensitive variables
for s := range LogSecretFilter.s {
if s != "" {
args[i] = strings.Replace(args[i], s, "<sensitive>", -1)
}
}
// Use packersdk.LogSecretFilter to scrub out sensitive variables
args[i] = packersdk.LogSecretFilter.FilterString(args[i])
args[i] = strings.Replace(v, ",", "%!(PACKER_COMMA)", -1)
args[i] = strings.Replace(args[i], "\r", "\\r", -1)
args[i] = strings.Replace(args[i], "\n", "\\n", -1)

View File

@ -19,7 +19,6 @@ import (
"github.com/aliyun/aliyun-oss-go-sdk/oss"
"github.com/hashicorp/hcl/v2/hcldec"
packerecs "github.com/hashicorp/packer/builder/alicloud/ecs"
"github.com/hashicorp/packer/packer"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
@ -160,7 +159,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
return errs
}
packer.LogSecretFilter.Set(p.config.AlicloudAccessKey, p.config.AlicloudSecretKey)
packersdk.LogSecretFilter.Set(p.config.AlicloudAccessKey, p.config.AlicloudSecretKey)
log.Println(p.config)
return nil
}

View File

@ -16,7 +16,6 @@ import (
"github.com/aws/aws-sdk-go/service/s3/s3manager"
"github.com/hashicorp/hcl/v2/hcldec"
awscommon "github.com/hashicorp/packer/builder/amazon/common"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/retry"
@ -126,7 +125,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
}
p.config.PollingConfig.LogEnvOverrideWarnings()
packer.LogSecretFilter.Set(p.config.AccessKey, p.config.SecretKey, p.config.Token)
packersdk.LogSecretFilter.Set(p.config.AccessKey, p.config.SecretKey, p.config.Token)
log.Println(p.config)
return nil
}

View File

@ -21,7 +21,6 @@ import (
"github.com/hashicorp/hcl/v2/hcldec"
"github.com/hashicorp/packer/builder/digitalocean"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
@ -144,7 +143,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
return errs
}
packer.LogSecretFilter.Set(p.config.SpacesKey, p.config.SpacesSecret, p.config.APIToken)
packersdk.LogSecretFilter.Set(p.config.SpacesKey, p.config.SpacesSecret, p.config.APIToken)
log.Println(p.config)
return nil
}

View File

@ -20,7 +20,6 @@ import (
"github.com/hashicorp/hcl/v2/hcldec"
"github.com/hashicorp/packer/builder/file"
"github.com/hashicorp/packer/builder/qemu"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
@ -101,7 +100,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
return errs
}
packer.LogSecretFilter.Set(p.config.APIKey, p.config.APISecret)
packersdk.LogSecretFilter.Set(p.config.APIKey, p.config.APISecret)
return nil
}

View File

@ -13,7 +13,6 @@ import (
"github.com/hashicorp/hcl/v2/hcldec"
ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/retry"
@ -150,7 +149,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
return errs
}
packer.LogSecretFilter.Set(p.config.PublicKey, p.config.PrivateKey)
packersdk.LogSecretFilter.Set(p.config.PublicKey, p.config.PrivateKey)
log.Println(p.config)
return nil
}

View File

@ -175,7 +175,7 @@ func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifa
}
encodedPassword, isSet := getEncodedPassword(ovftool_uri)
if isSet {
packer.LogSecretFilter.Set(encodedPassword)
packersdk.LogSecretFilter.Set(encodedPassword)
}
args, err := p.BuildArgs(source, ovftool_uri.String())