mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-04 21:01:36 +00:00
Validate device queries
Some checks failed
Build and test GAM / build (false, build, 1, Build Intel Ubuntu Jammy, ubuntu-22.04) (push) Has been cancelled
Build and test GAM / build (false, build, 10, Build x86_64 macOS 15, macos-15-intel) (push) Has been cancelled
Build and test GAM / build (false, build, 11, Build x86_64 macOS 26, macos-26-intel) (push) Has been cancelled
Build and test GAM / build (false, build, 12, Build Arm MacOS 26, macos-26) (push) Has been cancelled
Build and test GAM / build (false, build, 13, Build Intel Windows, windows-2025-vs2026) (push) Has been cancelled
Build and test GAM / build (false, build, 14, Build Arm Windows, windows-11-arm) (push) Has been cancelled
Build and test GAM / build (false, build, 2, Build Intel Ubuntu Noble, ubuntu-24.04) (push) Has been cancelled
Build and test GAM / build (false, build, 3, Build Arm Ubuntu Noble, ubuntu-24.04-arm) (push) Has been cancelled
Build and test GAM / build (false, build, 4, Build Arm Ubuntu Jammy, ubuntu-22.04-arm) (push) Has been cancelled
Build and test GAM / build (false, build, 5, Build Intel StaticX Legacy, ubuntu-22.04, yes) (push) Has been cancelled
Build and test GAM / build (false, build, 6, Build Arm StaticX Legacy, ubuntu-22.04-arm, yes) (push) Has been cancelled
Build and test GAM / build (false, build, 8, Build Arm MacOS 14, macos-14) (push) Has been cancelled
Build and test GAM / build (false, build, 9, Build Arm MacOS 15, macos-15) (push) Has been cancelled
Build and test GAM / build (false, test, 15, Test Python 3.10, ubuntu-24.04, 3.10) (push) Has been cancelled
Build and test GAM / build (false, test, 16, Test Python 3.11, ubuntu-24.04, 3.11) (push) Has been cancelled
Build and test GAM / build (false, test, 17, Test Python 3.12, ubuntu-24.04, 3.12) (push) Has been cancelled
Build and test GAM / build (false, test, 18, Test Python 3.13, ubuntu-24.04, 3.13) (push) Has been cancelled
Build and test GAM / build (false, test, 19, Test Python 3.15-dev, ubuntu-24.04, 3.15-dev) (push) Has been cancelled
Build and test GAM / build (true, test, 20, Test Python 3.14 freethread, ubuntu-24.04, 3.14) (push) Has been cancelled
Build and test GAM / publish (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Push wiki / pushwiki (push) Has been cancelled
Check for Google Root CA Updates / check-certs (push) Has been cancelled
Daily Dependency Pinning (2-Week Buffer) / pin-deps (push) Has been cancelled
Some checks failed
Build and test GAM / build (false, build, 1, Build Intel Ubuntu Jammy, ubuntu-22.04) (push) Has been cancelled
Build and test GAM / build (false, build, 10, Build x86_64 macOS 15, macos-15-intel) (push) Has been cancelled
Build and test GAM / build (false, build, 11, Build x86_64 macOS 26, macos-26-intel) (push) Has been cancelled
Build and test GAM / build (false, build, 12, Build Arm MacOS 26, macos-26) (push) Has been cancelled
Build and test GAM / build (false, build, 13, Build Intel Windows, windows-2025-vs2026) (push) Has been cancelled
Build and test GAM / build (false, build, 14, Build Arm Windows, windows-11-arm) (push) Has been cancelled
Build and test GAM / build (false, build, 2, Build Intel Ubuntu Noble, ubuntu-24.04) (push) Has been cancelled
Build and test GAM / build (false, build, 3, Build Arm Ubuntu Noble, ubuntu-24.04-arm) (push) Has been cancelled
Build and test GAM / build (false, build, 4, Build Arm Ubuntu Jammy, ubuntu-22.04-arm) (push) Has been cancelled
Build and test GAM / build (false, build, 5, Build Intel StaticX Legacy, ubuntu-22.04, yes) (push) Has been cancelled
Build and test GAM / build (false, build, 6, Build Arm StaticX Legacy, ubuntu-22.04-arm, yes) (push) Has been cancelled
Build and test GAM / build (false, build, 8, Build Arm MacOS 14, macos-14) (push) Has been cancelled
Build and test GAM / build (false, build, 9, Build Arm MacOS 15, macos-15) (push) Has been cancelled
Build and test GAM / build (false, test, 15, Test Python 3.10, ubuntu-24.04, 3.10) (push) Has been cancelled
Build and test GAM / build (false, test, 16, Test Python 3.11, ubuntu-24.04, 3.11) (push) Has been cancelled
Build and test GAM / build (false, test, 17, Test Python 3.12, ubuntu-24.04, 3.12) (push) Has been cancelled
Build and test GAM / build (false, test, 18, Test Python 3.13, ubuntu-24.04, 3.13) (push) Has been cancelled
Build and test GAM / build (false, test, 19, Test Python 3.15-dev, ubuntu-24.04, 3.15-dev) (push) Has been cancelled
Build and test GAM / build (true, test, 20, Test Python 3.14 freethread, ubuntu-24.04, 3.14) (push) Has been cancelled
Build and test GAM / publish (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Push wiki / pushwiki (push) Has been cancelled
Check for Google Root CA Updates / check-certs (push) Has been cancelled
Daily Dependency Pinning (2-Week Buffer) / pin-deps (push) Has been cancelled
This commit is contained in:
@@ -25,7 +25,7 @@ https://github.com/GAM-team/GAM/wiki
|
||||
"""
|
||||
|
||||
__author__ = 'GAM Team <google-apps-manager@googlegroups.com>'
|
||||
__version__ = '7.43.05'
|
||||
__version__ = '7.43.06'
|
||||
__license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'
|
||||
|
||||
# pylint: disable=wrong-import-position
|
||||
@@ -6071,6 +6071,20 @@ def getQueries(myarg):
|
||||
return [getString(Cmd.OB_QUERY)]
|
||||
return shlexSplitList(getString(Cmd.OB_QUERY_LIST))
|
||||
|
||||
def _validateDeviceQuery(entityType, query):
|
||||
if (':' not in query) or ('?' in query):
|
||||
Cmd.Backup()
|
||||
usageErrorExit(Msg.INVALID_DEVICE_QUERY.format(Ent.Singular(entityType), query))
|
||||
|
||||
def getDeviceQueries(myarg, entityType):
|
||||
if myarg in {'query', 'filter'}:
|
||||
queries = [getString(Cmd.OB_QUERY)]
|
||||
else:
|
||||
queries = shlexSplitList(getString(Cmd.OB_QUERY_LIST))
|
||||
for query in queries:
|
||||
_validateDeviceQuery(entityType, query)
|
||||
return queries
|
||||
|
||||
def convertEntityToList(entity, shlexSplit=False, nonListEntityType=False):
|
||||
if not entity:
|
||||
return []
|
||||
@@ -6756,6 +6770,7 @@ def getItemsToModify(entityType, entity, memberRoles=None, isSuspended=None, isA
|
||||
if entityType == Cmd.ENTITY_CROS_SN:
|
||||
queries = [f'id:{query}' for query in queries]
|
||||
for query in queries:
|
||||
_validateDeviceQuery(Ent.CROS_DEVICE, query)
|
||||
printGettingAllAccountEntities(Ent.CROS_DEVICE, query)
|
||||
try:
|
||||
result = callGAPIpages(cd.chromeosdevices(), 'list', 'chromeosdevices',
|
||||
@@ -6782,9 +6797,9 @@ def getItemsToModify(entityType, entity, memberRoles=None, isSuspended=None, isA
|
||||
includeChildOrgunits = entityType in Cmd.CROS_OU_CHILDREN_ENTITY_TYPES
|
||||
allQualifier = Msg.DIRECTLY_IN_THE.format(Ent.Choose(Ent.ORGANIZATIONAL_UNIT, numOus)) if not includeChildOrgunits else Msg.IN_THE.format(Ent.Choose(Ent.ORGANIZATIONAL_UNIT, numOus))
|
||||
if entityType in Cmd.CROS_OU_QUERY_ENTITY_TYPES:
|
||||
queries = getQueries('query')
|
||||
queries = getDeviceQueries('query', Ent.CROS_DEVICE)
|
||||
elif entityType in Cmd.CROS_OU_QUERIES_ENTITY_TYPES:
|
||||
queries = getQueries('queries')
|
||||
queries = getDeviceQueries('queries', Ent.CROS_DEVICE)
|
||||
else:
|
||||
queries = [None]
|
||||
for ou in ous:
|
||||
@@ -25361,7 +25376,7 @@ def doPrintCrOSDevices(entityList=None):
|
||||
selectionAllowed = False
|
||||
includeChildOrgunits = myarg in {Cmd.ENTITY_CROS_OU_AND_CHILDREN, Cmd.ENTITY_CROS_OUS_AND_CHILDREN}
|
||||
elif (selectionAllowed or queries == [None]) and myarg in {'query', 'queries'}:
|
||||
queries = getQueries(myarg)
|
||||
queries = getDeviceQueries(myarg, Ent.CROS_DEVICE)
|
||||
elif myarg.startswith('querytime'):
|
||||
queryTimes[myarg] = getTimeOrDeltaFromNow()[0:19]
|
||||
elif selectionAllowed and myarg == 'select':
|
||||
@@ -25640,7 +25655,7 @@ def doPrintCrOSActivity(entityList=None):
|
||||
selectionAllowed = False
|
||||
directlyInOU = myarg in {Cmd.ENTITY_CROS_OU, Cmd.ENTITY_CROS_OUS}
|
||||
elif (selectionAllowed or queries == [None]) and myarg in {'query', 'queries'}:
|
||||
queries = getQueries(myarg)
|
||||
queries = getDeviceQueries(myarg, Ent.CROS_DEVICE)
|
||||
elif myarg.startswith('querytime'):
|
||||
queryTimes[myarg] = getTimeOrDeltaFromNow()[0:19]
|
||||
elif selectionAllowed and myarg == 'select':
|
||||
@@ -26165,7 +26180,7 @@ def doMoveBrowsers():
|
||||
elif myarg in {'csv', 'csvfile'}:
|
||||
deviceIds.extend(getEntitiesFromCSVFile(False))
|
||||
elif myarg in {'query', 'queries'}:
|
||||
queries = getQueries(myarg)
|
||||
queries = getDeviceQueries(myarg, Ent.CHROME_BROWSER)
|
||||
elif myarg.startswith('querytime'):
|
||||
queryTimes[myarg] = getTimeOrDeltaFromNow()[0:19]
|
||||
elif myarg == 'browserou':
|
||||
@@ -26717,7 +26732,7 @@ def doPrintShowBrowsers():
|
||||
if csvPF and myarg == 'todrive':
|
||||
csvPF.GetTodriveParameters()
|
||||
elif myarg in {'query', 'queries'}:
|
||||
queries = getQueries(myarg)
|
||||
queries = getDeviceQueries(myarg, Ent.CHROME_BROWSER)
|
||||
elif myarg.startswith('querytime'):
|
||||
queryTimes[myarg] = getTimeOrDeltaFromNow()[0:19]
|
||||
elif myarg in {'ou', 'org', 'orgunit', 'browserou'}:
|
||||
@@ -26924,7 +26939,7 @@ def doPrintShowBrowserTokens():
|
||||
if csvPF and myarg == 'todrive':
|
||||
csvPF.GetTodriveParameters()
|
||||
elif myarg in {'query', 'queries'}:
|
||||
queries = getQueries(myarg)
|
||||
queries = getDeviceQueries(myarg, Ent.CHROME_BROWSER)
|
||||
elif myarg.startswith('querytime'):
|
||||
queryTimes[myarg] = getTimeOrDeltaFromNow()[0:19]
|
||||
elif myarg in {'ou', 'org', 'orgunit', 'browserou'}:
|
||||
@@ -31030,6 +31045,7 @@ def getCIDeviceEntity():
|
||||
if not name.startswith('devices/'):
|
||||
name = f'devices/{name}'
|
||||
return ([{'name': name}], ci, customer, True)
|
||||
_validateDeviceQuery(Ent.DEVICE, query)
|
||||
printGettingAllAccountEntities(Ent.DEVICE, query)
|
||||
pageMessage = getPageMessage()
|
||||
try:
|
||||
@@ -31066,6 +31082,7 @@ def getCIDeviceUserEntity():
|
||||
return ([{'name': name}], ci, customer, True)
|
||||
Cmd.Backup()
|
||||
invalidArgumentExit(DEVICE_USERNAME_FORMAT_REQUIRED)
|
||||
_validateDeviceQuery(Ent.DEVICE_USER, query)
|
||||
printGettingAllAccountEntities(Ent.DEVICE_USER, query)
|
||||
pageMessage = getPageMessage()
|
||||
try:
|
||||
@@ -31214,7 +31231,7 @@ def doSyncCIDevices():
|
||||
while Cmd.ArgumentsRemaining():
|
||||
myarg = getArgument()
|
||||
if myarg in ['filter', 'filters', 'query', 'queries']:
|
||||
queries = getQueries(myarg)
|
||||
queries = getDeviceQueries(myarg, Ent.COMPANY_DEVICE)
|
||||
elif myarg.startswith('querytime'):
|
||||
queryTimes[myarg] = getTimeOrDeltaFromNow()[0:19]
|
||||
elif myarg in {'csv', 'csvfile'}:
|
||||
@@ -31520,7 +31537,7 @@ def doPrintCIDevices():
|
||||
if csvPF and myarg == 'todrive':
|
||||
csvPF.GetTodriveParameters()
|
||||
elif myarg in ['filter', 'filters', 'query', 'queries']:
|
||||
queries = getQueries(myarg)
|
||||
queries = getDeviceQueries(myarg, entityType)
|
||||
elif myarg.startswith('querytime'):
|
||||
queryTimes[myarg] = getTimeOrDeltaFromNow()[0:19]
|
||||
elif myarg == 'orderby':
|
||||
@@ -31758,7 +31775,7 @@ def doPrintCIDeviceUsers():
|
||||
if not parent.startswith('devices/'):
|
||||
parent = f'devices/{parent}'
|
||||
elif myarg in ['filter', 'filters', 'query', 'queries']:
|
||||
queries = getQueries(myarg)
|
||||
queries = getDeviceQueries(myarg, Ent.DEVICE_USER)
|
||||
elif myarg.startswith('querytime'):
|
||||
queryTimes[myarg] = getTimeOrDeltaFromNow()[0:19]
|
||||
elif myarg == 'orderby':
|
||||
@@ -33406,6 +33423,7 @@ def getMobileDeviceEntity():
|
||||
query = None
|
||||
if not query:
|
||||
return ([{'resourceId': device, 'email': []} for device in getEntityList(Cmd.OB_MOBILE_ENTITY)], cd, True)
|
||||
_validateDeviceQuery(Ent.MOBILE_DEVICE, query)
|
||||
try:
|
||||
printGettingAllAccountEntities(Ent.MOBILE_DEVICE, query)
|
||||
devices = callGAPIpages(cd.mobiledevices(), 'list', 'mobiledevices',
|
||||
@@ -33716,7 +33734,7 @@ def doPrintMobileDevices():
|
||||
if myarg == 'todrive':
|
||||
csvPF.GetTodriveParameters()
|
||||
elif myarg in {'query', 'queries'}:
|
||||
queries = getQueries(myarg)
|
||||
queries = getDeviceQueries(myarg, Ent.MOBILE_DEVICE)
|
||||
elif myarg.startswith('querytime'):
|
||||
queryTimes[myarg] = getTimeOrDeltaFromNow()[0:19]
|
||||
elif myarg == 'orderby':
|
||||
|
||||
Reference in New Issue
Block a user