diff --git a/builder/alicloud/ecs/builder.go b/builder/alicloud/ecs/builder.go index 160fd734a..106ac4287 100644 --- a/builder/alicloud/ecs/builder.go +++ b/builder/alicloud/ecs/builder.go @@ -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 } diff --git a/builder/amazon/chroot/builder.go b/builder/amazon/chroot/builder.go index 5fdb9f315..79a99c43f 100644 --- a/builder/amazon/chroot/builder.go +++ b/builder/amazon/chroot/builder.go @@ -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") diff --git a/builder/amazon/common/step_get_password.go b/builder/amazon/common/step_get_password.go index f1e1410cc..b35de86cd 100644 --- a/builder/amazon/common/step_get_password.go +++ b/builder/amazon/common/step_get_password.go @@ -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 } diff --git a/builder/amazon/ebs/builder.go b/builder/amazon/ebs/builder.go index 5831b7648..17edd4744 100644 --- a/builder/amazon/ebs/builder.go +++ b/builder/amazon/ebs/builder.go @@ -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 diff --git a/builder/amazon/ebssurrogate/builder.go b/builder/amazon/ebssurrogate/builder.go index 93ffa92dd..030255413 100644 --- a/builder/amazon/ebssurrogate/builder.go +++ b/builder/amazon/ebssurrogate/builder.go @@ -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 diff --git a/builder/amazon/ebsvolume/builder.go b/builder/amazon/ebsvolume/builder.go index ac6bd8250..b7e872ad9 100644 --- a/builder/amazon/ebsvolume/builder.go +++ b/builder/amazon/ebsvolume/builder.go @@ -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 diff --git a/builder/amazon/instance/builder.go b/builder/amazon/instance/builder.go index f5b263bdd..a06fd4656 100644 --- a/builder/amazon/instance/builder.go +++ b/builder/amazon/instance/builder.go @@ -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 diff --git a/builder/azure/arm/config.go b/builder/azure/arm/config.go index ee050f9e5..b193ea099 100644 --- a/builder/azure/arm/config.go +++ b/builder/azure/arm/config.go @@ -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 == "" { diff --git a/builder/azure/chroot/builder.go b/builder/azure/chroot/builder.go index 23a7f6092..ab3b74346 100644 --- a/builder/azure/chroot/builder.go +++ b/builder/azure/chroot/builder.go @@ -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 } diff --git a/builder/azure/dtl/config.go b/builder/azure/dtl/config.go index aa49c7ccb..de4ed8138 100644 --- a/builder/azure/dtl/config.go +++ b/builder/azure/dtl/config.go @@ -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 diff --git a/builder/azure/dtl/step_save_winrm_password.go b/builder/azure/dtl/step_save_winrm_password.go index ab81bcc80..569f82557 100644 --- a/builder/azure/dtl/step_save_winrm_password.go +++ b/builder/azure/dtl/step_save_winrm_password.go @@ -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 } diff --git a/builder/digitalocean/config.go b/builder/digitalocean/config.go index 529ee481f..3f372783c 100644 --- a/builder/digitalocean/config.go +++ b/builder/digitalocean/config.go @@ -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 } diff --git a/builder/googlecompute/step_create_windows_password.go b/builder/googlecompute/step_create_windows_password.go index 54d6f75e5..3c012a2f3 100644 --- a/builder/googlecompute/step_create_windows_password.go +++ b/builder/googlecompute/step_create_windows_password.go @@ -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 } diff --git a/builder/hcloud/config.go b/builder/hcloud/config.go index 3dae727a3..023448dc3 100644 --- a/builder/hcloud/config.go +++ b/builder/hcloud/config.go @@ -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 } diff --git a/builder/hyperone/config.go b/builder/hyperone/config.go index b8fca7937..65ed2e577 100644 --- a/builder/hyperone/config.go +++ b/builder/hyperone/config.go @@ -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 } diff --git a/builder/jdcloud/builder.go b/builder/jdcloud/builder.go index fbbb9881e..dee0cd225 100644 --- a/builder/jdcloud/builder.go +++ b/builder/jdcloud/builder.go @@ -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 } diff --git a/builder/linode/config.go b/builder/linode/config.go index 0c84ffdcc..947fd8271 100644 --- a/builder/linode/config.go +++ b/builder/linode/config.go @@ -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 } diff --git a/builder/oneandone/config.go b/builder/oneandone/config.go index ebe1ccaed..283a78e8d 100644 --- a/builder/oneandone/config.go +++ b/builder/oneandone/config.go @@ -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 } diff --git a/builder/openstack/builder.go b/builder/openstack/builder.go index 206f6146f..17ee636a3 100644 --- a/builder/openstack/builder.go +++ b/builder/openstack/builder.go @@ -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 } diff --git a/builder/openstack/step_get_password.go b/builder/openstack/step_get_password.go index 6d77bbb71..34737fedb 100644 --- a/builder/openstack/step_get_password.go +++ b/builder/openstack/step_get_password.go @@ -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 } diff --git a/builder/oracle/oci/step_get_default_credentials.go b/builder/oracle/oci/step_get_default_credentials.go index 902f8c050..62b79a48c 100644 --- a/builder/oracle/oci/step_get_default_credentials.go +++ b/builder/oracle/oci/step_get_default_credentials.go @@ -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 } diff --git a/builder/osc/bsu/builder.go b/builder/osc/bsu/builder.go index d5b05252e..8498936e1 100644 --- a/builder/osc/bsu/builder.go +++ b/builder/osc/bsu/builder.go @@ -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 } diff --git a/builder/osc/bsusurrogate/builder.go b/builder/osc/bsusurrogate/builder.go index f7c607004..f3877cc06 100644 --- a/builder/osc/bsusurrogate/builder.go +++ b/builder/osc/bsusurrogate/builder.go @@ -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 } diff --git a/builder/osc/bsuvolume/builder.go b/builder/osc/bsuvolume/builder.go index 7a3d6d3a4..9509be632 100644 --- a/builder/osc/bsuvolume/builder.go +++ b/builder/osc/bsuvolume/builder.go @@ -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 } diff --git a/builder/osc/chroot/builder.go b/builder/osc/chroot/builder.go index b15441256..7a72943d7 100644 --- a/builder/osc/chroot/builder.go +++ b/builder/osc/chroot/builder.go @@ -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 } diff --git a/builder/osc/common/step_get_password.go b/builder/osc/common/step_get_password.go index c68570601..f3f3694b1 100644 --- a/builder/osc/common/step_get_password.go +++ b/builder/osc/common/step_get_password.go @@ -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 } diff --git a/builder/profitbricks/config.go b/builder/profitbricks/config.go index a086e64db..20bd7e99e 100644 --- a/builder/profitbricks/config.go +++ b/builder/profitbricks/config.go @@ -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 } diff --git a/builder/proxmox/common/config.go b/builder/proxmox/common/config.go index 6ed893dbd..83e3c3433 100644 --- a/builder/proxmox/common/config.go +++ b/builder/proxmox/common/config.go @@ -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 == "" { diff --git a/builder/scaleway/config.go b/builder/scaleway/config.go index d65c37ea6..914796ff1 100644 --- a/builder/scaleway/config.go +++ b/builder/scaleway/config.go @@ -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 } diff --git a/builder/tencentcloud/cvm/builder.go b/builder/tencentcloud/cvm/builder.go index 4d2c2c653..2f2a8acb0 100644 --- a/builder/tencentcloud/cvm/builder.go +++ b/builder/tencentcloud/cvm/builder.go @@ -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 } diff --git a/builder/ucloud/uhost/builder.go b/builder/ucloud/uhost/builder.go index c0d239dc7..02a9da6cd 100644 --- a/builder/ucloud/uhost/builder.go +++ b/builder/ucloud/uhost/builder.go @@ -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 } diff --git a/builder/yandex/access_config.go b/builder/yandex/access_config.go index 9554d0b83..413e4e617 100644 --- a/builder/yandex/access_config.go +++ b/builder/yandex/access_config.go @@ -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 != "" { diff --git a/hcl2template/parser.go b/hcl2template/parser.go index 2a856a16f..32c437a61 100644 --- a/hcl2template/parser.go +++ b/hcl2template/parser.go @@ -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 }) diff --git a/main.go b/main.go index 3041a22e5..91e84db13 100644 --- a/main.go +++ b/main.go @@ -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 { diff --git a/packer/logs.go b/packer-plugin-sdk/packer/logs.go similarity index 72% rename from packer/logs.go rename to packer-plugin-sdk/packer/logs.go index e510fd069..209b66ca3 100644 --- a/packer/logs.go +++ b/packer-plugin-sdk/packer/logs.go @@ -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, "", -1) + } + } + return message +} + func (l *secretFilter) get() (s []string) { l.m.Lock() defer l.m.Unlock() diff --git a/packer-plugin-sdk/shell-local/localexec/run_and_stream.go b/packer-plugin-sdk/shell-local/localexec/run_and_stream.go index c5f932015..9555d2660 100644 --- a/packer-plugin-sdk/shell-local/localexec/run_and_stream.go +++ b/packer-plugin-sdk/shell-local/localexec/run_and_stream.go @@ -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:]) diff --git a/packer/core.go b/packer/core.go index 218c764a8..0c2759f01 100644 --- a/packer/core.go +++ b/packer/core.go @@ -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 diff --git a/packer/core_test.go b/packer/core_test.go index 2c5c70aa7..0b27ffb27 100644 --- a/packer/core_test.go +++ b/packer/core_test.go @@ -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{}) } } diff --git a/packer/ui.go b/packer/ui.go index 820992d57..52db011fa 100644 --- a/packer/ui.go +++ b/packer/ui.go @@ -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, "", -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, "", -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, "", -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, "", -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) diff --git a/post-processor/alicloud-import/post-processor.go b/post-processor/alicloud-import/post-processor.go index 5d9a4a7f1..e3f673071 100644 --- a/post-processor/alicloud-import/post-processor.go +++ b/post-processor/alicloud-import/post-processor.go @@ -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 } diff --git a/post-processor/amazon-import/post-processor.go b/post-processor/amazon-import/post-processor.go index 4931e2968..4bfc5d38c 100644 --- a/post-processor/amazon-import/post-processor.go +++ b/post-processor/amazon-import/post-processor.go @@ -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 } diff --git a/post-processor/digitalocean-import/post-processor.go b/post-processor/digitalocean-import/post-processor.go index 93666fd99..42ff238bf 100644 --- a/post-processor/digitalocean-import/post-processor.go +++ b/post-processor/digitalocean-import/post-processor.go @@ -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 } diff --git a/post-processor/exoscale-import/post-processor.go b/post-processor/exoscale-import/post-processor.go index 679eeb0f1..ed088398b 100644 --- a/post-processor/exoscale-import/post-processor.go +++ b/post-processor/exoscale-import/post-processor.go @@ -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 } diff --git a/post-processor/ucloud-import/post-processor.go b/post-processor/ucloud-import/post-processor.go index bead1f18a..1380afaf9 100644 --- a/post-processor/ucloud-import/post-processor.go +++ b/post-processor/ucloud-import/post-processor.go @@ -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 } diff --git a/post-processor/vsphere/post-processor.go b/post-processor/vsphere/post-processor.go index 6d0198437..0c15aa400 100644 --- a/post-processor/vsphere/post-processor.go +++ b/post-processor/vsphere/post-processor.go @@ -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())