Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package google-guest-agent for openSUSE:Factory checked in at 2022-05-05 23:07:26 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/google-guest-agent (Old) and /work/SRC/openSUSE:Factory/.google-guest-agent.new.1538 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "google-guest-agent" Thu May 5 23:07:26 2022 rev:12 rq:975194 version:20220429.00 Changes: -------- --- /work/SRC/openSUSE:Factory/google-guest-agent/google-guest-agent.changes 2022-04-13 21:07:10.140688902 +0200 +++ /work/SRC/openSUSE:Factory/.google-guest-agent.new.1538/google-guest-agent.changes 2022-05-05 23:08:08.173687835 +0200 @@ -1,0 +2,6 @@ +Thu May 5 12:37:36 UTC 2022 - John Paul Adrian Glaubitz <adrian.glaub...@suse.com> + +- Update to version 20220429.00 + * Move some functionality to a utils module (#162) + +------------------------------------------------------------------- Old: ---- guest-agent-20220412.00.tar.gz New: ---- guest-agent-20220429.00.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ google-guest-agent.spec ++++++ --- /var/tmp/diff_new_pack.ORDzR5/_old 2022-05-05 23:08:08.841688669 +0200 +++ /var/tmp/diff_new_pack.ORDzR5/_new 2022-05-05 23:08:08.845688673 +0200 @@ -24,7 +24,7 @@ %global import_path %{provider_prefix} Name: google-guest-agent -Version: 20220412.00 +Version: 20220429.00 Release: 0 Summary: Google Cloud Guest Agent License: Apache-2.0 ++++++ _service ++++++ --- /var/tmp/diff_new_pack.ORDzR5/_old 2022-05-05 23:08:08.929688779 +0200 +++ /var/tmp/diff_new_pack.ORDzR5/_new 2022-05-05 23:08:08.933688783 +0200 @@ -3,8 +3,8 @@ <param name="url">https://github.com/GoogleCloudPlatform/guest-agent/</param> <param name="scm">git</param> <param name="exclude">.git</param> - <param name="versionformat">20220412.00</param> - <param name="revision">20220412.00</param> + <param name="versionformat">20220429.00</param> + <param name="revision">20220429.00</param> <param name="changesgenerate">enable</param> </service> <service name="recompress" mode="disabled"> @@ -15,7 +15,7 @@ <param name="basename">guest-agent</param> </service> <service name="go_modules" mode="disabled"> - <param name="archive">guest-agent-20220412.00.tar.gz</param> + <param name="archive">guest-agent-20220429.00.tar.gz</param> </service> </services> ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.ORDzR5/_old 2022-05-05 23:08:08.985688849 +0200 +++ /var/tmp/diff_new_pack.ORDzR5/_new 2022-05-05 23:08:08.989688853 +0200 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/GoogleCloudPlatform/guest-agent/</param> - <param name="changesrevision">25c217feb6b4394e5aa5c7743ffdf592421174d7</param></service></servicedata> + <param name="changesrevision">23c66a1d7d710364fcdeb5736de6f6ac0454e2ec</param></service></servicedata> (No newline at EOF) ++++++ guest-agent-20220412.00.tar.gz -> guest-agent-20220429.00.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/guest-agent-20220412.00/google_guest_agent/addresses.go new/guest-agent-20220429.00/google_guest_agent/addresses.go --- old/guest-agent-20220412.00/google_guest_agent/addresses.go 2022-04-12 18:35:56.000000000 +0200 +++ new/guest-agent-20220429.00/google_guest_agent/addresses.go 2022-04-29 19:34:57.000000000 +0200 @@ -25,6 +25,7 @@ "strings" "time" + "github.com/GoogleCloudPlatform/guest-agent/utils" "github.com/GoogleCloudPlatform/guest-logging-go/logger" ) @@ -87,13 +88,13 @@ func compareRoutes(configuredRoutes, desiredRoutes []string) (toAdd, toRm []string) { for _, desiredRoute := range desiredRoutes { - if !containsString(desiredRoute, configuredRoutes) { + if !utils.ContainsString(desiredRoute, configuredRoutes) { toAdd = append(toAdd, desiredRoute) } } for _, configuredRoute := range configuredRoutes { - if !containsString(configuredRoute, desiredRoutes) { + if !utils.ContainsString(configuredRoute, desiredRoutes) { toRm = append(toRm, configuredRoute) } } @@ -220,7 +221,7 @@ for idx := range interfaces { var filteredForwardedIps []string for _, ip := range interfaces[idx].ForwardedIps { - if !containsString(ip, wsfcAddrs) { + if !utils.ContainsString(ip, wsfcAddrs) { filteredForwardedIps = append(filteredForwardedIps, ip) } } @@ -228,7 +229,7 @@ var filteredTargetInstanceIps []string for _, ip := range interfaces[idx].TargetInstanceIps { - if !containsString(ip, wsfcAddrs) { + if !utils.ContainsString(ip, wsfcAddrs) { filteredTargetInstanceIps = append(filteredTargetInstanceIps, ip) } } @@ -319,7 +320,7 @@ for _, ni := range newMetadata.Instance.NetworkInterfaces { iface, err := getInterfaceByMAC(ni.Mac) if err != nil { - if !containsString(ni.Mac, badMAC) { + if !utils.ContainsString(ni.Mac, badMAC) { logger.Errorf("Error getting interface: %s", err) badMAC = append(badMAC, ni.Mac) } @@ -352,7 +353,7 @@ } for _, ip := range configuredIPs { // Only add to `forwardedIPs` if it is recorded in the registry. - if containsString(ip, regFwdIPs) { + if utils.ContainsString(ip, regFwdIPs) { forwardedIPs = append(forwardedIPs, ip) } } @@ -395,14 +396,14 @@ var registryEntries []string for _, ip := range wantIPs { // If the IP is not in toAdd, add to registry list and continue. - if !containsString(ip, toAdd) { + if !utils.ContainsString(ip, toAdd) { registryEntries = append(registryEntries, ip) continue } var err error if runtime.GOOS == "windows" { // Don't addAddress if this is already configured. - if !containsString(ip, configuredIPs) { + if !utils.ContainsString(ip, configuredIPs) { err = addAddress(net.ParseIP(ip), net.IPv4Mask(255, 255, 255, 255), uint32(iface.Index)) } } else { @@ -418,7 +419,7 @@ for _, ip := range toRm { var err error if runtime.GOOS == "windows" { - if !containsString(ip, configuredIPs) { + if !utils.ContainsString(ip, configuredIPs) { continue } err = removeAddress(net.ParseIP(ip), uint32(iface.Index)) @@ -511,7 +512,7 @@ for _, ni := range newMetadata.Instance.NetworkInterfaces[1:] { iface, err := getInterfaceByMAC(ni.Mac) if err != nil { - if !containsString(ni.Mac, badMAC) { + if !utils.ContainsString(ni.Mac, badMAC) { logger.Errorf("Error getting interface: %s", err) badMAC = append(badMAC, ni.Mac) } @@ -527,7 +528,7 @@ } iface, err := getInterfaceByMAC(ni.Mac) if err != nil { - if !containsString(ni.Mac, badMAC) { + if !utils.ContainsString(ni.Mac, badMAC) { logger.Errorf("Error getting interface: %s", err) badMAC = append(badMAC, ni.Mac) } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/guest-agent-20220412.00/google_guest_agent/diagnostics.go new/guest-agent-20220429.00/google_guest_agent/diagnostics.go --- old/guest-agent-20220412.00/google_guest_agent/diagnostics.go 2022-04-12 18:35:56.000000000 +0200 +++ new/guest-agent-20220429.00/google_guest_agent/diagnostics.go 2022-04-29 19:34:57.000000000 +0200 @@ -20,8 +20,8 @@ "reflect" "strconv" "sync/atomic" - "time" + "github.com/GoogleCloudPlatform/guest-agent/utils" "github.com/GoogleCloudPlatform/guest-logging-go/logger" ) @@ -42,15 +42,15 @@ } func (k diagnosticsEntry) expired() bool { - t, err := time.Parse(time.RFC3339, k.ExpireOn) + expired, err := utils.CheckExpired(k.ExpireOn) if err != nil { - if !containsString(k.ExpireOn, badExpire) { - logger.Errorf("Error parsing time: %s", err) + if !utils.ContainsString(k.ExpireOn, badExpire) { + logger.Errorf("error parsing time: %s", err) badExpire = append(badExpire, k.ExpireOn) } return true } - return t.Before(time.Now()) + return expired } type diagnosticsMgr struct{} @@ -100,7 +100,7 @@ } strEntry := newMetadata.Instance.Attributes.Diagnostics - if containsString(strEntry, diagnosticsEntries) { + if utils.ContainsString(strEntry, diagnosticsEntries) { return nil } diagnosticsEntries = append(diagnosticsEntries, strEntry) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/guest-agent-20220412.00/google_guest_agent/main.go new/guest-agent-20220429.00/google_guest_agent/main.go --- old/guest-agent-20220412.00/google_guest_agent/main.go 2022-04-12 18:35:56.000000000 +0200 +++ new/guest-agent-20220429.00/google_guest_agent/main.go 2022-04-29 19:34:57.000000000 +0200 @@ -270,15 +270,6 @@ return execResult } -func containsString(s string, ss []string) bool { - for _, a := range ss { - if a == s { - return true - } - } - return false -} - func logFormatWindows(e logger.LogEntry) string { now := time.Now().Format("2006/01/02 15:04:05") // 2006/01/02 15:04:05 GCEGuestAgent This is a log message. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/guest-agent-20220412.00/google_guest_agent/main_test.go new/guest-agent-20220429.00/google_guest_agent/main_test.go --- old/guest-agent-20220412.00/google_guest_agent/main_test.go 2022-04-12 18:35:56.000000000 +0200 +++ new/guest-agent-20220429.00/google_guest_agent/main_test.go 2022-04-29 19:34:57.000000000 +0200 @@ -13,23 +13,3 @@ // limitations under the License. package main - -import ( - "testing" -) - -func TestContainsString(t *testing.T) { - table := []struct { - a string - slice []string - want bool - }{ - {"a", []string{"a", "b"}, true}, - {"c", []string{"a", "b"}, false}, - } - for _, tt := range table { - if got, want := containsString(tt.a, tt.slice), tt.want; got != want { - t.Errorf("containsString(%s, %v) incorrect return: got %v, want %t", tt.a, tt.slice, got, want) - } - } -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/guest-agent-20220412.00/google_guest_agent/metadata.go new/guest-agent-20220429.00/google_guest_agent/metadata.go --- old/guest-agent-20220412.00/google_guest_agent/metadata.go 2022-04-12 18:35:56.000000000 +0200 +++ new/guest-agent-20220429.00/google_guest_agent/metadata.go 2022-04-29 19:34:57.000000000 +0200 @@ -25,6 +25,7 @@ "strings" "time" + "github.com/GoogleCloudPlatform/guest-agent/utils" "github.com/GoogleCloudPlatform/guest-logging-go/logger" ) @@ -140,7 +141,7 @@ for _, jskey := range strings.Split(s, "\n") { var wk windowsKey if err := json.Unmarshal([]byte(jskey), &wk); err != nil { - if !containsString(jskey, badKeys) { + if !utils.ContainsString(jskey, badKeys) { logger.Errorf("failed to unmarshal windows key from metadata: %s", err) badKeys = append(badKeys, jskey) } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/guest-agent-20220412.00/google_guest_agent/non_windows_accounts.go new/guest-agent-20220429.00/google_guest_agent/non_windows_accounts.go --- old/guest-agent-20220412.00/google_guest_agent/non_windows_accounts.go 2022-04-12 18:35:56.000000000 +0200 +++ new/guest-agent-20220429.00/google_guest_agent/non_windows_accounts.go 2022-04-29 19:34:57.000000000 +0200 @@ -17,7 +17,6 @@ import ( "bufio" "bytes" - "encoding/json" "fmt" "io/ioutil" "os" @@ -26,8 +25,8 @@ "sort" "strconv" "strings" - "time" + "github.com/GoogleCloudPlatform/guest-agent/utils" "github.com/GoogleCloudPlatform/guest-logging-go/logger" ) @@ -182,6 +181,8 @@ return nil } +var badSSHKeys []string + // getUserKeys returns the keys which are not expired and non-expiring key. // valid formats are: // user:ssh-rsa [KEY_VALUE] [USERNAME] @@ -190,43 +191,22 @@ func getUserKeys(mdkeys []string) map[string][]string { mdKeyMap := make(map[string][]string) for i := 0; i < len(mdkeys); i++ { - key := strings.Trim(mdkeys[i], " ") - if key == "" { - logger.Debugf("invalid ssh key entry: %q", key) - continue - } - idx := strings.Index(key, ":") - if idx == -1 { - logger.Debugf("invalid ssh key entry: %q", key) - continue - } - user := key[:idx] - if user == "" { - logger.Debugf("invalid ssh key entry: %q", key) - continue - } - fields := strings.SplitN(key, " ", 4) - if len(fields) == 3 && fields[2] == "google-ssh" { - logger.Debugf("invalid ssh key entry: %q", key) - // expiring key without expiration format. - continue - } - if len(fields) > 3 { - lkey := linuxKey{} - if err := json.Unmarshal([]byte(fields[3]), &lkey); err != nil { - // invalid expiration format. - logger.Debugf("invalid ssh key entry: %q", key) - continue - } - if lkey.expired() { - logger.Debugf("expired ssh key entry: %q", key) + trimmedKey := strings.Trim(mdkeys[i], " ") + if trimmedKey != "" { + user, keyVal, err := utils.GetUserKey(trimmedKey) + if err != nil { + if !utils.ContainsString(trimmedKey, badSSHKeys) { + logger.Errorf("%s: %s", err.Error(), trimmedKey) + badSSHKeys = append(badSSHKeys, trimmedKey) + } continue } + + // key which is not expired or non-expiring key, add it. + userKeys := mdKeyMap[user] + userKeys = append(userKeys, keyVal) + mdKeyMap[user] = userKeys } - // key which is not expired or non-expiring key, add it. - userKeys := mdKeyMap[user] - userKeys = append(userKeys, key[idx+1:]) - mdKeyMap[user] = userKeys } return mdKeyMap } @@ -330,21 +310,6 @@ return res, nil } -type linuxKey windowsKey - -// expired returns true if the key's expireOn field is in the past, false otherwise. -func (k linuxKey) expired() bool { - t, err := time.Parse("2006-01-02T15:04:05-0700", k.ExpireOn) - if err != nil { - if !containsString(k.ExpireOn, badExpire) { - logger.Errorf("Error parsing time: %v.", err) - badExpire = append(badExpire, k.ExpireOn) - } - return true - } - return t.Before(time.Now()) -} - // Replaces {user} or {group} in command string. Supports legacy python-era // user command overrides. func createUserGroupCmd(cmd, user, group string) *exec.Cmd { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/guest-agent-20220412.00/google_guest_agent/windows_accounts.go new/guest-agent-20220429.00/google_guest_agent/windows_accounts.go --- old/guest-agent-20220412.00/google_guest_agent/windows_accounts.go 2022-04-12 18:35:56.000000000 +0200 +++ new/guest-agent-20220429.00/google_guest_agent/windows_accounts.go 2022-04-29 19:34:57.000000000 +0200 @@ -27,8 +27,8 @@ "hash" "math/big" "reflect" - "time" + "github.com/GoogleCloudPlatform/guest-agent/utils" "github.com/GoogleCloudPlatform/guest-logging-go/logger" ) @@ -111,15 +111,15 @@ var badExpire []string func (k windowsKey) expired() bool { - t, err := time.Parse(time.RFC3339, k.ExpireOn) + expired, err := utils.CheckExpired(k.ExpireOn) if err != nil { - if !containsString(k.ExpireOn, badExpire) { + if !utils.ContainsString(k.ExpireOn, badExpire) { logger.Errorf("error parsing time: %s", err) badExpire = append(badExpire, k.ExpireOn) } return true } - return t.Before(time.Now()) + return expired } func (k windowsKey) createOrResetPwd() (*credsJSON, error) { @@ -281,7 +281,7 @@ for _, s := range oldStrKeys { var key windowsKey if err := json.Unmarshal([]byte(s), &key); err != nil { - if !containsString(s, badReg) { + if !utils.ContainsString(s, badReg) { logger.Errorf("Bad windows key from registry: %s", err) badReg = append(badReg, s) } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/guest-agent-20220412.00/utils/main.go new/guest-agent-20220429.00/utils/main.go --- old/guest-agent-20220412.00/utils/main.go 1970-01-01 01:00:00.000000000 +0100 +++ new/guest-agent-20220429.00/utils/main.go 2022-04-29 19:34:57.000000000 +0200 @@ -0,0 +1,92 @@ +// Copyright 2022 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Utilities for Google Guest Agent and Google Authorized Keys + +package utils + +import ( + "encoding/json" + "errors" + "strings" + "time" +) + +//ContainsString checks for the presence of a string in a slice. +func ContainsString(s string, ss []string) bool { + for _, a := range ss { + if a == s { + return true + } + } + return false +} + +type sshKeyData struct { + ExpireOn string + UserName string +} + +//CheckExpired takes a time string and determines if it represents a time in the past. +func CheckExpired(expireOn string) (bool, error) { + t, err := time.Parse(time.RFC3339, expireOn) + if err != nil { + t2, err2 := time.Parse("2006-01-02T15:04:05-0700", expireOn) + if err2 != nil { + return true, err //Return RFC3339 error + } + t = t2 + } + return t.Before(time.Now()), nil + +} + +//GetUserKey takes a string and determines if it is a valid SSH key and returns +//the user and key if valid, nil otherwise. +func GetUserKey(rawKey string) (string, string, error) { + + key := strings.Trim(rawKey, " ") + if key == "" { + return "", "", errors.New("Invalid ssh key entry - empty key") + } + idx := strings.Index(key, ":") + if idx == -1 { + return "", "", errors.New("Invalid ssh key entry - unrecognized format") + } + user := key[:idx] + if user == "" { + return "", "", errors.New("Invalid ssh key entry - user missing") + } + fields := strings.SplitN(key, " ", 4) + if len(fields) == 3 && fields[2] == "google-ssh" { + // expiring key without expiration format. + return "", "", errors.New("Invalid ssh key entry - expiration missing") + } + if len(fields) > 3 { + lkey := sshKeyData{} + if err := json.Unmarshal([]byte(fields[3]), &lkey); err != nil { + // invalid expiration format. + return "", "", err + } + expired, err := CheckExpired(lkey.ExpireOn) + if err != nil { + return "", "", err + } + if expired { + return "", "", errors.New("Invalid ssh key entry - expired key") + } + } + + return user, key[idx+1:], nil +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/guest-agent-20220412.00/utils/main_test.go new/guest-agent-20220429.00/utils/main_test.go --- old/guest-agent-20220412.00/utils/main_test.go 1970-01-01 01:00:00.000000000 +0100 +++ new/guest-agent-20220429.00/utils/main_test.go 2022-04-29 19:34:57.000000000 +0200 @@ -0,0 +1,61 @@ +// Copyright 2022 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package utils + +import ( + "testing" +) + +func TestContainsString(t *testing.T) { + table := []struct { + a string + slice []string + want bool + }{ + {"a", []string{"a", "b"}, true}, + {"c", []string{"a", "b"}, false}, + } + for _, tt := range table { + if got, want := ContainsString(tt.a, tt.slice), tt.want; got != want { + t.Errorf("containsString(%s, %v) incorrect return: got %v, want %t", tt.a, tt.slice, got, want) + } + } +} + +func TestGetUserKey(t *testing.T) { + table := []struct { + key string + user string + keyVal string + haserr bool + }{ + {`usera:ssh-rsa AAAA1234 google-ssh {"userName":"us...@example.com","expireOn":"2095-04-23T12:34:56+0000"}`, + "usera", `ssh-rsa AAAA1234 google-ssh {"userName":"us...@example.com","expireOn":"2095-04-23T12:34:56+0000"}`, false}, + {`usera:ssh-rsa AAAA1234 google-ssh {"userName":"us...@example.com","expireOn":"2021-04-23T12:34:56+0000"}`, "", "", true}, + {`usera:ssh-rsa AAAA1234 google-ssh {"userName":"us...@example.com","expireOn":"Apri 4, 2056"}`, "", "", true}, + {`usera:ssh-rsa AAAA1234 google-ssh`, "", "", true}, + {" ", "", "", true}, + {"ssh-rsa AAAA1234", "", "", true}, + {":ssh-rsa AAAA1234", "", "", true}, + } + + for _, tt := range table { + u, k, err := GetUserKey(tt.key) + e := err != nil + if u != tt.user || k != tt.keyVal || e != tt.haserr { + t.Errorf("GetUserKey(%s) incorrect return: got user: %s, key: %s, error: %v - want user %s, key: %s, error: %v", tt.key, u, k, e, tt.user, tt.keyVal, tt.haserr) + } + } +} ++++++ vendor.tar.gz ++++++