Improve device query validation

This commit is contained in:
Ross Scroggs
2026-05-18 17:38:49 -07:00
parent dfe01e5272
commit 56c2b77f25
3 changed files with 13 additions and 3 deletions

View File

@@ -1,3 +1,7 @@
7.43.07
Improved validation of `<QueryCrOS>`, `<QueryDevice>` and `<QueryMobile>`.
7.43.06
Updated commands that use `<QueryCrOS>`, `<QueryDevice>` or `<QueryMobile>` to validate

View File

@@ -25,7 +25,7 @@ https://github.com/GAM-team/GAM/wiki
"""
__author__ = 'GAM Team <google-apps-manager@googlegroups.com>'
__version__ = '7.43.06'
__version__ = '7.43.07'
__license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'
# pylint: disable=wrong-import-position
@@ -6072,7 +6072,13 @@ def getQueries(myarg):
return shlexSplitList(getString(Cmd.OB_QUERY_LIST))
def _validateDeviceQuery(entityType, query):
if (':' not in query) or ('?' in query):
if ':' in query:
qfield, qvalue = query.split(':', 1)
qfield = qfield.strip()
else:
qfield = ''
qvalue = query
if (not qfield) or (not qvalue) or ('?' in query):
Cmd.Backup()
usageErrorExit(Msg.INVALID_DEVICE_QUERY.format(Ent.Singular(entityType), query))

View File

@@ -312,7 +312,7 @@ INVALID_ALIAS = 'Invalid Alias'
INVALID_ATTENDEE_CHANGE = 'Invalid attendee change "{0}"'
INVALID_CHARSET = 'Invalid charset "{0}"'
INVALID_DATE_TIME_RANGE = '{0} {1} must be greater than/equal to {2} {3}'
INVALID_DEVICE_QUERY = 'Invalid {0} query "{1}"; it must contain a ":" and must not contain a "?"'
INVALID_DEVICE_QUERY = 'Invalid {0} query "{1}"; it must be if the form "field:value" and must not contain a "?"'
INVALID_EMOJI_NAME = '{0} does not match pattern :[0-9a-z_-]:'
INVALID_ENTITY = 'Invalid {0}, {1}'
INVALID_EVENT_TIMERANGE = '{0} {1} must be less than {2}'