Bug 2041454 - Garbage values accepted for `--reference-policy` in `oc import-image` without any error
Summary: Garbage values accepted for `--reference-policy` in `oc import-image` without...
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: oc
Version: 4.9
Hardware: Unspecified
OS: Unspecified
Target Milestone: ---
: 4.11.0
Assignee: Arda Guclu
QA Contact: zhou ying
Depends On:
TreeView+ depends on / blocked
Reported: 2022-01-17 11:36 UTC by Mayur Deore
Modified: 2022-08-10 10:42 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: No Doc Update
Doc Text:
Clone Of:
Last Closed: 2022-08-10 10:42:31 UTC
Target Upstream Version:

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
Github openshift oc pull 1108 0 None open Bug 2041454: Validate reference-policy for import-image command 2022-04-11 06:38:52 UTC
Red Hat Product Errata RHSA-2022:5069 0 None None None 2022-08-10 10:42:52 UTC

Description Mayur Deore 2022-01-17 11:36:14 UTC
Description of problem:
- Garbage values accepted for `--reference-policy` in `oc import-image` without any error. 

- Command 'oc import-image' has an option '--reference-policy' that sets a value of the resulting ImageStreamTag (JSON path tag.referencePolicy.type). '--reference-policy=sources' results in 'tag.referencePolicy:type: Source' whereas '--reference-policy=local' results in 'tag.referencePolicy.type: Local'. Ommitting the option results in 'tag.referencePolicy.type: Source', i.e. 'source' is the default value. So far as documented. So far so good.

- Now the interesting part: Specifying '--reference-policy' with any other value than 'source' or 'local' results in 'tag.referencePolicy.type: Source' - without any warning or error message.

- This is not acceptable. Specifying '--reference-policy' with any other value than 'source' or 'local' must result in an appropriate error message and abort the 'oc import-image' command completely.

- I additionally suggested to also make the command option '--reference-policy' a bit more lenient, i.e. treat the lower and upper case in the given values equally. (E.g. 'local' = 'Local')  This is due to the different use of lower case values and upper case values with the command option '--reference-policy' on the one hand and 'tag.referencePolicy.type' in the resource ImageStreamTag on the other hand.

Version-Release number of selected component (if applicable):
- OC Client Client Version: 4.9.12

How reproducible:
Easily reproducible using the following steps 

Steps to Reproduce:
1. oc import-image registry.redhat.io/openshift3/jenkins-2-rhel7 --reference-policy=sdfsdfds --confirm 

Actual results:
 - We don't get any error msg and we get `Source` as the default `reference-policy`
[quicklab@upi-0 ~]$ oc get is jenkins-2-rhel7 -o yaml | grep -A1 referencePolicy
      type: Source

Expected results:
 We should get an error msg when we pass garbage values to `--reference-policy=sdfsdfds` other than `source` and `local` and import should fail.

Additional info:
 You can do this test with any image.

Comment 2 zhou ying 2022-04-13 01:59:00 UTC
checked with latest oc client, the issue has fixed:

[root@localhost ~]# oc version --client
Client Version: 4.11.0-202204122151.p0.ge88515d.assembly.stream-e88515d

oc import-image registry.redhat.io/openshift3/jenkins-2-rhel7 --reference-policy=sdfsdfds --confirm
error: valid reference policy values are source or local

Comment 5 errata-xmlrpc 2022-08-10 10:42:31 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Important: OpenShift Container Platform 4.11.0 bug fix and security update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


Note You need to log in before you can comment on or make changes to this bug.