From 34bf205d3740e7ddf78d1ab2a39c34e43d088c7d Mon Sep 17 00:00:00 2001 From: Ross Scroggs Date: Wed, 7 Apr 2021 09:34:31 -0700 Subject: [PATCH 1/3] Fix indentation (#1357) --- src/gam/gapi/chromepolicy.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gam/gapi/chromepolicy.py b/src/gam/gapi/chromepolicy.py index 6b9e644d..1153b5fb 100644 --- a/src/gam/gapi/chromepolicy.py +++ b/src/gam/gapi/chromepolicy.py @@ -301,10 +301,10 @@ def update_policy(): value = value.split(',') if myarg == 'chrome.users.chromebrowserupdates' and \ cased_field == 'targetVersionPrefixSetting': - if value.find('-') != -1: - channel, minus = value.split('-') - milestone = gapi_chromehistory.get_relative_milestone(channel, int(minus)) - value = f'{milestone}.' + if value.find('-') != -1: + channel, minus = value.split('-') + milestone = gapi_chromehistory.get_relative_milestone(channel, int(minus)) + value = f'{milestone}.' body['requests'][-1]['policyValue']['value'][cased_field] = value body['requests'][-1]['updateMask'] += f'{cased_field},' i += 2 From 8682e66eb0220a5671848af6aff717ee67868ef3 Mon Sep 17 00:00:00 2001 From: Jay Lee Date: Wed, 7 Apr 2021 13:01:27 -0400 Subject: [PATCH 2/3] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b0911000..5749e760 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -108,7 +108,7 @@ jobs: path: | ~/python ~/ssl - key: ${{ matrix.os }}-${{ matrix.jid }}-20210325 + key: ${{ matrix.os }}-${{ matrix.jid }}-20210407 - name: Set env variables env: From 4da413222050fb5f82d2b17df569addd1c91db92 Mon Sep 17 00:00:00 2001 From: Ross Scroggs Date: Wed, 7 Apr 2021 12:09:45 -0700 Subject: [PATCH 3/3] Validate chrome.users.chromebrowserupdates targetVersionPrefixSetting channel-offset (#1359) * Validate chrome.users.chromebrowserupdates targetVersionPrefixSetting channel-offset * Fix typo, add extended channel Pass extended on to maintainer of : https://developer.chrome.com/docs/versionhistory/reference/#channel-identifiers --- src/gam/gapi/chromehistory.py | 3 ++- src/gam/gapi/chromepolicy.py | 22 +++++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/gam/gapi/chromehistory.py b/src/gam/gapi/chromehistory.py index 2891c8bc..e757cf1e 100644 --- a/src/gam/gapi/chromehistory.py +++ b/src/gam/gapi/chromehistory.py @@ -29,7 +29,7 @@ CHROME_PLATFORM_CHOICE_MAP = { 'linux': 'linux', 'mac': 'mac', 'macarm64': 'mac_arm64', - 'sebview': 'webview', + 'webview': 'webview', 'win': 'win', 'win64': 'win64', } @@ -39,6 +39,7 @@ CHROME_CHANNEL_CHOICE_MAP = { 'canary': 'canary', 'canaryasan': 'canary_asan', 'dev': 'dev', + 'extended': 'extended', 'stable': 'stable', } diff --git a/src/gam/gapi/chromepolicy.py b/src/gam/gapi/chromepolicy.py index 1153b5fb..f8ffeb1e 100644 --- a/src/gam/gapi/chromepolicy.py +++ b/src/gam/gapi/chromepolicy.py @@ -1,5 +1,6 @@ """Chrome Browser Cloud Management API calls""" +import re import sys import googleapiclient.errors @@ -300,11 +301,22 @@ def update_policy(): elif vtype in ['TYPE_LIST']: value = value.split(',') if myarg == 'chrome.users.chromebrowserupdates' and \ - cased_field == 'targetVersionPrefixSetting': - if value.find('-') != -1: - channel, minus = value.split('-') - milestone = gapi_chromehistory.get_relative_milestone(channel, int(minus)) - value = f'{milestone}.' + cased_field == 'targetVersionPrefixSetting': + mg = re.compile(r'^([a-z]+)-(\d+)$').match(value) + if mg: + channel = mg.group(1).lower().replace('_', '') + minus = mg.group(2) + if channel not in gapi_chromehistory.CHROME_CHANNEL_CHOICE_MAP: + expected_channels = ', '.join(gapi_chromehistory.CHROME_CHANNEL_CHOICE_MAP) + msg = f'Expected {myarg} {cased_field} channel to be one of ' \ + f'{expected_channels}, got {channel}' + controlflow.system_error_exit(8, msg) + milestone = gapi_chromehistory.get_relative_milestone( + gapi_chromehistory.CHROME_CHANNEL_CHOICE_MAP[channel], int(minus)) + if not milestone: + msg = f'{myarg} {cased_field} channel {channel} offset {minus} does not exist' + controlflow.system_error_exit(8, msg) + value = f'{milestone}.' body['requests'][-1]['policyValue']['value'][cased_field] = value body['requests'][-1]['updateMask'] += f'{cased_field},' i += 2