-
Notifications
You must be signed in to change notification settings - Fork 85
Modify the automatic determination of the Config type #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
a5a3b45 to
45af0d8
Compare
|
ping @vbatts @wking @xiekeyang @coolljt0725 PTAL |
|
I have no opinion on peek-inside type detection implementations ;).
|
image/autodetect.go
Outdated
|
|
||
| case header.MediaType == "" && header.SchemaVersion == 0 && header.Config != nil: | ||
| // config files don't have mediaType/schemaVersion header | ||
| case header.RootFS != nil: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is good to check rootfs(required) instead config(optional).
However, statement header.MediaType == "" && header.SchemaVersion == 0 had better to be kept, which are also terms differ with other json descriptors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think only need a unique attribute can determine the Config type, the other on some superfluous
|
@xiekeyang I am not sure what this is trying to do. Unfortunately, the use of mediaType to detect the type doesn't work, since descriptors describe the target to which they are pointing. Really, trying to ascertain what a thing is with having a qualified reference presents a host of security problems. Really, you want to instruct the process what the type of the target item is dispatch to a handler. The type resolution is a trusted, deterministic process, either by assuming that all incoming objects are of the same type (such as descriptors) or through a secured mediatype (such as a signed metadata provider). If we really want content auto detection, we need to have a hard look at the spec, but I don't think is really needed in any real use case. |
|
I think there may be JSON file here to verify the location of the problem, but this method of verification I think it is possible, I have already explained above |
|
@stevvooe |
|
@xiekeyang Correct. @vbatts Do we have an open issue for this? |
|
Means the JSON related validation into image - spec? |
I think so. And media type auto-detection might had better to be removed. |
45af0d8 to
542326c
Compare
99dcb01 to
61daf0d
Compare
|
@xiekeyang @stevvooe What do you think of this change? |
| case "application/octet-stream": | ||
| return TypeImage, nil | ||
|
|
||
| case "text/plain; charset=utf-8": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is charset coming from? This looks really wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh,This is the original code, the results by http.DetectContentType to determine the format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason autodetect can't be the default? This particular media type doesn't make sense. Media types don't actually have charsets (that is content types).
17c1b4a to
6017ccc
Compare
|
@xiekeyang @coolljt0725 On this PR, I think I can do is make such a change.PTAL |
|
Detection/validation stuff might need a issue involving design spec firstly. Based on which we should get the agreement. And then start to implement. |
|
Is this still needed? |
|
Closed. |
6017ccc to
ad2fc03
Compare
|
I reopen this pr because the current |
|
@q384566678 Where does this get used? The autodetection looks right but it will be naive to the introduction of new types. |
@stevvooe Above is an example of an Because through |
|
@q384566678 But why are we using |
|
@stevvooe Because we entered |
|
@q384566678 What is the use case of autodetect? This seems like the wrong direction. |
|
@stevvooe The function of this function is when you execute the command, if not enter type, to determine the type. And there is no problem. |
|
@q384566678 What? This seems incorrect. How can you validate something if you don't know the type? |
|
@stevvooe Uh, as I said. if you don't enter the type (or you don't know the type), the |
|
@xiekeyang @coolljt0725 PTAL |
|
@xiekeyang @stevvooe @coolljt0725 @cyphar I think this problem needs to have a result, it's been a long time. I still think it's necessary to do this, or there will be validation errors like I said above. |
|
I still feel that we should follow [1] and [2]. [1]#62 (comment) |
|
@q384566678 I am not sure how to make this more clear: autodetection of types in OCI images is not a supported concept. It is insecure and broken in practice (see the history of the tar format). If we keep trying to do this, without major design changes, we will have the same broken behavior. Let's remove autodetection and find ways in which we can accurately and correctly resolve types. |
|
@stevvooe ok, I'll do it. |
@stevvooe Do you have a specific link to this ? I can not find it.Thanks. |
|
@stevvooe Can you explain the above question? |
|
ping @stevvooe |
f85c031 to
83a481d
Compare
|
ping @stevvooe @coolljt0725 @xiekeyang How about this revision? |
cmd/oci-image-tool/validate.go
Outdated
| return schema.ValidatorMediaTypeImageIndex.Validate(f) | ||
| case image.TypeConfig: | ||
| return schema.ValidatorMediaTypeImageConfig.Validate(f) | ||
| case "JSON": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we introduce a new type JSON is a good idea here, JSON is not any type in image spec. I think it's better to keep the old way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also think the previous method is good, and I have not thought of other methods at present, but the suggestion of @stevvooe is to replace the previous method.
Signed-off-by: zhouhao <[email protected]>
83a481d to
9795a19
Compare
|
I think we should close this PR. |
|
@Mashimiao I think we can close this. |
The Config attribute may be empty, so cannot be used as the basis for judging the Config type, should use the RootFS is inevitable in this attribute to judge .
Signed-off-by: zhouhao [email protected]