Hello community, here is the log from the commit of package container-diff for openSUSE:Factory checked in at 2018-04-20 17:26:35 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/container-diff (Old) and /work/SRC/openSUSE:Factory/.container-diff.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "container-diff" Fri Apr 20 17:26:35 2018 rev:4 rq:595547 version:0.9.0 Changes: -------- --- /work/SRC/openSUSE:Factory/container-diff/container-diff.changes 2018-03-22 12:11:45.875377534 +0100 +++ /work/SRC/openSUSE:Factory/.container-diff.new/container-diff.changes 2018-04-20 17:26:45.504439058 +0200 @@ -1,0 +2,21 @@ +Wed Apr 11 07:34:21 UTC 2018 - [email protected] + +- Build container-diff as PIC (via `-buildmode=pie`). + +- Exclude ppc64le from tests. + +------------------------------------------------------------------- +Wed Apr 11 07:01:52 UTC 2018 - [email protected] + +- Update container-diff to v0.9.0: + * Add metadata diffing + * Sanitize filepaths before joining to prevent filepath traversal + * Fix appending of latest tag to tar files + * Correctly clean up image filesystems + * Set/unset write bit when unpacking directories out of permission scope + * Add all docker config fields to image config + * Sort maps before diffing to prevent flaky results + * Correctly handle case where no image source is parsed + * Cleanup image source directory + +------------------------------------------------------------------- Old: ---- container-diff-0.8.0.tar.xz New: ---- container-diff-0.9.0.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ container-diff.spec ++++++ --- /var/tmp/diff_new_pack.1QUCGu/_old 2018-04-20 17:26:46.684396270 +0200 +++ /var/tmp/diff_new_pack.1QUCGu/_new 2018-04-20 17:26:46.688396125 +0200 @@ -18,7 +18,7 @@ %define project github.com/GoogleCloudPlatform/container-diff Name: container-diff -Version: 0.8.0 +Version: 0.9.0 Release: 0 Summary: Analyze and compare container images License: Apache-2.0 @@ -61,7 +61,8 @@ # Build container-diff export BUILDTAGS="" go build -tags "$BUILDTAGS" \ - -i -ldflags '-s -w -X %{project}/version.version=v%{version}' \ + -buildmode=pie \ + -ldflags '-s -w -X %{project}/version.version=v%{version}' \ -o bin/container-diff \ %{project} @@ -74,9 +75,11 @@ cp -avr * $HOME/go/src/%{project} cd $HOME/go/src/%{project} -# Test container-diff +# Test container-diff. Exclude ppc64le, which has known issue with gotest. PKG_LIST=$(go list ./... | grep -v %{project}/vendor}) +%ifnarch ppc64le go test $PKG_LIST +%endif %install cd $HOME/go/src/%{project} ++++++ _service ++++++ --- /var/tmp/diff_new_pack.1QUCGu/_old 2018-04-20 17:26:46.732394530 +0200 +++ /var/tmp/diff_new_pack.1QUCGu/_new 2018-04-20 17:26:46.732394530 +0200 @@ -2,8 +2,8 @@ <service name="tar_scm" mode="disabled"> <param name="url">https://github.com/GoogleCloudPlatform/container-diff</param> <param name="scm">git</param> -<param name="versionformat">0.8.0</param> -<param name="revision">v0.8.0</param> +<param name="versionformat">0.9.0</param> +<param name="revision">v0.9.0</param> </service> <service name="recompress" mode="disabled"> <param name="file">container-diff-*.tar</param> ++++++ container-diff-0.8.0.tar.xz -> container-diff-0.9.0.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/CONTRIBUTING.md new/container-diff-0.9.0/CONTRIBUTING.md --- old/container-diff-0.8.0/CONTRIBUTING.md 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/CONTRIBUTING.md 2018-04-10 22:10:52.000000000 +0200 @@ -3,6 +3,39 @@ We'd love to accept your patches and contributions to this project. There are just a few small guidelines you need to follow. +## Setup + +If you haven't written Go code on your machine before, first follow the official +Golang instructions for setting up your environment: https://golang.org/doc/code.html + +Once you have your environment set up, create a fork of the container-diff repository +with your personal GitHub account. Then, clone the fork into your `$GOPATH`: + +```bash +git clone [email protected]:<your_account>/container-diff.git +$GOPATH/src/github.com/GoogleCloudPlatform && +cd $GOPATH/src/github.com/GoogleCloudPlatform/container-diff && +git remote add upstream [email protected]:GoogleCloudPlatform/container-diff.git +``` + +The last command here sets the official repository as an upstream repository for +your fork, so you can keep your fork in sync with `MASTER`: + +```bash +(container-diff) git pull upstream master && git push origin master +``` + +## Building + +From the project root, run `make clean && make`. + +## Code reviews + +All submissions, including submissions by project members, require review. We +use GitHub pull requests for this purpose. Consult +[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more +information on using pull requests. + ## Contributor License Agreement Contributions to this project must be accompanied by a Contributor License @@ -15,13 +48,6 @@ (even if it was for a different project), you probably don't need to do it again. -## Code reviews - -All submissions, including submissions by project members, require review. We -use GitHub pull requests for this purpose. Consult -[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more -information on using pull requests. - ## Tests Before sending a PR, please make sure the included tests pass. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/Gopkg.lock new/container-diff-0.9.0/Gopkg.lock --- old/container-diff-0.8.0/Gopkg.lock 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/Gopkg.lock 2018-04-10 22:10:52.000000000 +0200 @@ -282,6 +282,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "6e818cd6f09d26d5ae0fe9f66a9dd88de47a87a1b4a5048422947f43e7838f9b" + inputs-digest = "011f13273effca41fb1b82358a8c8848c419b09bc3f37e07dd7213d3f8836c31" solver-name = "gps-cdcl" solver-version = 1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/Makefile new/container-diff-0.9.0/Makefile --- old/container-diff-0.8.0/Makefile 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/Makefile 2018-04-10 22:10:52.000000000 +0200 @@ -1,4 +1,4 @@ -# Copyright 2016 Google, Inc. All rights reserved. +# Copyright 2018 Google, Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ # Bump these on release VERSION_MAJOR ?= 0 -VERSION_MINOR ?= 8 +VERSION_MINOR ?= 9 VERSION_BUILD ?= 0 VERSION ?= v$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_BUILD) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/cmd/analyze.go new/container-diff-0.9.0/cmd/analyze.go --- old/container-diff-0.8.0/cmd/analyze.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/cmd/analyze.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -87,7 +87,7 @@ return fmt.Errorf("Error performing image analysis: %s", err) } - output.PrintToStdErr("Retrieving analyses") + output.PrintToStdErr("Retrieving analyses\n") outputResults(analyses) if save { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/cmd/analyze_test.go new/container-diff-0.9.0/cmd/analyze_test.go --- old/container-diff-0.8.0/cmd/analyze_test.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/cmd/analyze_test.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/cmd/diff.go new/container-diff-0.9.0/cmd/diff.go --- old/container-diff-0.8.0/cmd/diff.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/cmd/diff.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -113,7 +113,7 @@ defer pkgutil.CleanupImage(*imageMap[image2Arg]) } - output.PrintToStdErr("Computing diffs") + output.PrintToStdErr("Computing diffs\n") req := differs.DiffRequest{ Image1: *imageMap[image1Arg], Image2: *imageMap[image2Arg], @@ -125,7 +125,7 @@ outputResults(diffs) if filename != "" { - output.PrintToStdErr("Computing filename diffs") + output.PrintToStdErr("Computing filename diffs\n") err := diffFile(imageMap[image1Arg], imageMap[image2Arg]) if err != nil { return err diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/cmd/diff_test.go new/container-diff-0.9.0/cmd/diff_test.go --- old/container-diff-0.8.0/cmd/diff_test.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/cmd/diff_test.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/cmd/root.go new/container-diff-0.9.0/cmd/root.go --- old/container-diff-0.8.0/cmd/root.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/cmd/root.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -129,7 +129,7 @@ if pkgutil.IsTar(image) { return &pkgutil.TarPrepper{ - Source: image, + Source: filepath.Clean(image), Client: cli, }, nil } @@ -154,6 +154,7 @@ if err != nil { return nil, err } + defer src.Close() if !noCache { cacheDir, err := cacheDir() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/cmd/root_test.go new/container-diff-0.9.0/cmd/root_test.go --- old/container-diff-0.8.0/cmd/root_test.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/cmd/root_test.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/cmd/util/output/output.go new/container-diff-0.9.0/cmd/util/output/output.go --- old/container-diff-0.8.0/cmd/util/output/output.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/cmd/util/output/output.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/cmd/version.go new/container-diff-0.9.0/cmd/version.go --- old/container-diff-0.8.0/cmd/version.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/cmd/version.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/code-of-conduct.md new/container-diff-0.9.0/code-of-conduct.md --- old/container-diff-0.8.0/code-of-conduct.md 1970-01-01 01:00:00.000000000 +0100 +++ new/container-diff-0.9.0/code-of-conduct.md 2018-04-10 22:10:52.000000000 +0200 @@ -0,0 +1,92 @@ +# Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of +experience, education, socio-economic status, nationality, personal appearance, +race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, or to ban temporarily or permanently any +contributor for other behaviors that they deem inappropriate, threatening, +offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +This Code of Conduct also applies outside the project spaces when the Project +Steward has a reasonable belief that an individual's behavior may have a +negative impact on the project or its community. + +## Conflict Resolution + +We do not believe that all conflict is bad; healthy debate and disagreement +often yield positive results. However, it is never okay to be disrespectful or +to engage in behavior that violates the project’s code of conduct. + +If you see someone violating the code of conduct, you are encouraged to address +the behavior directly with those involved. Many issues can be resolved quickly +and easily, and this gives people more control over the outcome of their +dispute. If you are unable to resolve the matter for any reason, or if the +behavior is threatening or harassing, report it. We are dedicated to providing +an environment where participants feel welcome and safe. + +Reports should be directed to the maintainers, the Project Steward(s) for +container-diff. It is the Project Steward’s duty to receive and address reported +violations of the code of conduct. They will then work with a committee +consisting of representatives from the Open Source Programs Office and the +Google Open Source Strategy team. If for any reason you are uncomfortable +reaching out the Project Steward, please email [email protected]. + +We will investigate every complaint, but you may not receive a direct response. +We will use our discretion in determining when and how to follow up on reported +incidents, which may range from not taking action to permanent expulsion from +the project and project-sponsored spaces. We will notify the accused of the +report and provide them an opportunity to discuss it before any action is taken. +The identity of the reporter will be omitted from the details of the report +supplied to the accused. In potentially harmful situations, such as ongoing +harassment or threats to anyone's safety, we may take action without notice. + +## Attribution + +This Code of Conduct is adapted from the Contributor Covenant, version 1.4, +available at +https://www.contributor-covenant.org/version/1/4/code-of-conduct.html diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/differs/BUILD.bazel new/container-diff-0.9.0/differs/BUILD.bazel --- old/container-diff-0.8.0/differs/BUILD.bazel 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/differs/BUILD.bazel 2018-04-10 22:10:52.000000000 +0200 @@ -7,6 +7,7 @@ "differs.go", "file_diff.go", "history_diff.go", + "metadata_diff.go", "node_diff.go", "package_differs.go", "pip_diff.go", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/differs/apt_diff.go new/container-diff-0.9.0/differs/apt_diff.go --- old/container-diff-0.8.0/differs/apt_diff.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/differs/apt_diff.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/differs/apt_diff_test.go new/container-diff-0.9.0/differs/apt_diff_test.go --- old/container-diff-0.8.0/differs/apt_diff_test.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/differs/apt_diff_test.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/differs/differs.go new/container-diff-0.9.0/differs/differs.go --- old/container-diff-0.8.0/differs/differs.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/differs/differs.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -42,12 +42,13 @@ } var Analyzers = map[string]Analyzer{ - "history": HistoryAnalyzer{}, - "file": FileAnalyzer{}, - "apt": AptAnalyzer{}, - "rpm": RPMAnalyzer{}, - "pip": PipAnalyzer{}, - "node": NodeAnalyzer{}, + "history": HistoryAnalyzer{}, + "metadata": MetadataAnalyzer{}, + "file": FileAnalyzer{}, + "apt": AptAnalyzer{}, + "rpm": RPMAnalyzer{}, + "pip": PipAnalyzer{}, + "node": NodeAnalyzer{}, } func (req DiffRequest) GetDiff() (map[string]util.Result, error) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/differs/differs_test.go new/container-diff-0.9.0/differs/differs_test.go --- old/container-diff-0.8.0/differs/differs_test.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/differs/differs_test.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/differs/file_diff.go new/container-diff-0.9.0/differs/file_diff.go --- old/container-diff-0.8.0/differs/file_diff.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/differs/file_diff.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/differs/history_diff.go new/container-diff-0.9.0/differs/history_diff.go --- old/container-diff-0.8.0/differs/history_diff.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/differs/history_diff.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/differs/metadata_diff.go new/container-diff-0.9.0/differs/metadata_diff.go --- old/container-diff-0.8.0/differs/metadata_diff.go 1970-01-01 01:00:00.000000000 +0100 +++ new/container-diff-0.9.0/differs/metadata_diff.go 2018-04-10 22:10:52.000000000 +0200 @@ -0,0 +1,66 @@ +/* +Copyright 2017 Google, Inc. All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package differs + +import ( + pkgutil "github.com/GoogleCloudPlatform/container-diff/pkg/util" + "github.com/GoogleCloudPlatform/container-diff/util" +) + +type MetadataAnalyzer struct { +} + +type MetadataDiff struct { + Adds []string + Dels []string +} + +func (a MetadataAnalyzer) Name() string { + return "MetadataAnalyzer" +} + +func (a MetadataAnalyzer) Diff(image1, image2 pkgutil.Image) (util.Result, error) { + diff, err := getMetadataDiff(image1, image2) + return &util.MetadataDiffResult{ + Image1: image1.Source, + Image2: image2.Source, + DiffType: "Metadata", + Diff: diff, + }, err +} + +func (a MetadataAnalyzer) Analyze(image pkgutil.Image) (util.Result, error) { + analysis := getMetadataList(image) + return &util.ListAnalyzeResult{ + Image: image.Source, + AnalyzeType: "Metadata", + Analysis: analysis, + }, nil +} + +func getMetadataDiff(image1, image2 pkgutil.Image) (MetadataDiff, error) { + m1 := getMetadataList(image1) + m2 := getMetadataList(image2) + + adds := util.GetAdditions(m1, m2) + dels := util.GetDeletions(m1, m2) + return MetadataDiff{adds, dels}, nil +} + +func getMetadataList(image pkgutil.Image) []string { + return image.Config.Config.AsList() +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/differs/node_diff.go new/container-diff-0.9.0/differs/node_diff.go --- old/container-diff-0.8.0/differs/node_diff.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/differs/node_diff.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/differs/node_diff_test.go new/container-diff-0.9.0/differs/node_diff_test.go --- old/container-diff-0.8.0/differs/node_diff_test.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/differs/node_diff_test.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/differs/package_differs.go new/container-diff-0.9.0/differs/package_differs.go --- old/container-diff-0.8.0/differs/package_differs.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/differs/package_differs.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/differs/pip_diff.go new/container-diff-0.9.0/differs/pip_diff.go --- old/container-diff-0.8.0/differs/pip_diff.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/differs/pip_diff.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/differs/pip_diff_test.go new/container-diff-0.9.0/differs/pip_diff_test.go --- old/container-diff-0.8.0/differs/pip_diff_test.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/differs/pip_diff_test.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/differs/rpm_diff.go new/container-diff-0.9.0/differs/rpm_diff.go --- old/container-diff-0.8.0/differs/rpm_diff.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/differs/rpm_diff.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/differs/rpm_diff_test.go new/container-diff-0.9.0/differs/rpm_diff_test.go --- old/container-diff-0.8.0/differs/rpm_diff_test.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/differs/rpm_diff_test.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/differs/testDirs/pipTests2/packagesMultiVersion/usr/local/lib/python2.7/site-packages/script3.py new/container-diff-0.9.0/differs/testDirs/pipTests2/packagesMultiVersion/usr/local/lib/python2.7/site-packages/script3.py --- old/container-diff-0.8.0/differs/testDirs/pipTests2/packagesMultiVersion/usr/local/lib/python2.7/site-packages/script3.py 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/differs/testDirs/pipTests2/packagesMultiVersion/usr/local/lib/python2.7/site-packages/script3.py 2018-04-10 22:10:52.000000000 +0200 @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2017 Google, Inc. All rights reserved. +# Copyright 2018 Google, Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/differs/testDirs/pipTests2/packagesMultiVersion/usr/local/lib/python3.6/site-packages/script1.py new/container-diff-0.9.0/differs/testDirs/pipTests2/packagesMultiVersion/usr/local/lib/python3.6/site-packages/script1.py --- old/container-diff-0.8.0/differs/testDirs/pipTests2/packagesMultiVersion/usr/local/lib/python3.6/site-packages/script1.py 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/differs/testDirs/pipTests2/packagesMultiVersion/usr/local/lib/python3.6/site-packages/script1.py 2018-04-10 22:10:52.000000000 +0200 @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2017 Google, Inc. All rights reserved. +# Copyright 2018 Google, Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/differs/testDirs/pipTests2/packagesMultiVersion/usr/local/lib/python3.6/site-packages/script2.py new/container-diff-0.9.0/differs/testDirs/pipTests2/packagesMultiVersion/usr/local/lib/python3.6/site-packages/script2.py --- old/container-diff-0.8.0/differs/testDirs/pipTests2/packagesMultiVersion/usr/local/lib/python3.6/site-packages/script2.py 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/differs/testDirs/pipTests2/packagesMultiVersion/usr/local/lib/python3.6/site-packages/script2.py 2018-04-10 22:10:52.000000000 +0200 @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2017 Google, Inc. All rights reserved. +# Copyright 2018 Google, Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/differs/testDirs/pipTests2/packagesOneLayer/usr/local/lib/python3.6/site-packages/script1.py new/container-diff-0.9.0/differs/testDirs/pipTests2/packagesOneLayer/usr/local/lib/python3.6/site-packages/script1.py --- old/container-diff-0.8.0/differs/testDirs/pipTests2/packagesOneLayer/usr/local/lib/python3.6/site-packages/script1.py 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/differs/testDirs/pipTests2/packagesOneLayer/usr/local/lib/python3.6/site-packages/script1.py 2018-04-10 22:10:52.000000000 +0200 @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2017 Google, Inc. All rights reserved. +# Copyright 2018 Google, Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/differs/testDirs/pipTests2/packagesOneLayer/usr/local/lib/python3.6/site-packages/script2.py new/container-diff-0.9.0/differs/testDirs/pipTests2/packagesOneLayer/usr/local/lib/python3.6/site-packages/script2.py --- old/container-diff-0.8.0/differs/testDirs/pipTests2/packagesOneLayer/usr/local/lib/python3.6/site-packages/script2.py 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/differs/testDirs/pipTests2/packagesOneLayer/usr/local/lib/python3.6/site-packages/script2.py 2018-04-10 22:10:52.000000000 +0200 @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2017 Google, Inc. All rights reserved. +# Copyright 2018 Google, Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/docker_diff.bzl new/container-diff-0.9.0/docker_diff.bzl --- old/container-diff-0.8.0/docker_diff.bzl 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/docker_diff.bzl 2018-04-10 22:10:52.000000000 +0200 @@ -1,4 +1,4 @@ -# Copyright 2017 Google, Inc. All rights reserved. +# Copyright 2018 Google, Inc. All rights reserved. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/main.go new/container-diff-0.9.0/main.go --- old/container-diff-0.8.0/main.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/main.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/pkg/cache/file_cache.go new/container-diff-0.9.0/pkg/cache/file_cache.go --- old/container-diff-0.8.0/pkg/cache/file_cache.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/pkg/cache/file_cache.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/pkg/image/mutable_source.go new/container-diff-0.9.0/pkg/image/mutable_source.go --- old/container-diff-0.8.0/pkg/image/mutable_source.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/pkg/image/mutable_source.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/pkg/image/mutable_source_test.go new/container-diff-0.9.0/pkg/image/mutable_source_test.go --- old/container-diff-0.8.0/pkg/image/mutable_source_test.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/pkg/image/mutable_source_test.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/pkg/image/proxy_types.go new/container-diff-0.9.0/pkg/image/proxy_types.go --- old/container-diff-0.8.0/pkg/image/proxy_types.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/pkg/image/proxy_types.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ if err != nil { return nil, err } + defer src.Close() img, err := ref.NewImage(nil) if err != nil { return nil, err diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/pkg/util/BUILD.bazel new/container-diff-0.9.0/pkg/util/BUILD.bazel --- old/container-diff-0.8.0/pkg/util/BUILD.bazel 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/pkg/util/BUILD.bazel 2018-04-10 22:10:52.000000000 +0200 @@ -24,6 +24,7 @@ "//vendor/github.com/containers/image/types:go_default_library", "//vendor/github.com/docker/docker/client:go_default_library", "//vendor/github.com/docker/docker/pkg/system:go_default_library", + "//vendor/github.com/pkg/errors:go_default_library", "//vendor/github.com/sirupsen/logrus:go_default_library", ], ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/pkg/util/cloud_prepper.go new/container-diff-0.9.0/pkg/util/cloud_prepper.go --- old/container-diff-0.8.0/pkg/util/cloud_prepper.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/pkg/util/cloud_prepper.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/pkg/util/daemon_prepper.go new/container-diff-0.9.0/pkg/util/daemon_prepper.go --- old/container-diff-0.8.0/pkg/util/daemon_prepper.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/pkg/util/daemon_prepper.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -60,6 +60,7 @@ if err != nil { return "", err } + defer src.Close() sanitizedName := strings.Replace(p.Source, ":", "", -1) sanitizedName = strings.Replace(sanitizedName, "/", "", -1) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/pkg/util/docker_utils.go new/container-diff-0.9.0/pkg/util/docker_utils.go --- old/container-diff-0.8.0/pkg/util/docker_utils.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/pkg/util/docker_utils.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/pkg/util/fs_utils.go new/container-diff-0.9.0/pkg/util/fs_utils.go --- old/container-diff-0.8.0/pkg/util/fs_utils.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/pkg/util/fs_utils.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/pkg/util/image_prep_utils.go new/container-diff-0.9.0/pkg/util/image_prep_utils.go --- old/container-diff-0.8.0/pkg/util/image_prep_utils.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/pkg/util/image_prep_utils.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -20,8 +20,10 @@ "archive/tar" "encoding/json" "errors" + "fmt" "io/ioutil" "os" + "sort" "strings" "github.com/GoogleCloudPlatform/container-diff/cmd/util/output" @@ -85,13 +87,60 @@ } type ConfigObject struct { - Env []string `json:"Env"` - Entrypoint []string `json:"Entrypoint"` + Hostname string + Domainname string + User string + AttachStdin bool + AttachStdout bool + AttachStderr bool ExposedPorts map[string]struct{} `json:"ExposedPorts"` - Cmd []string `json:"Cmd"` - Volumes map[string]struct{} `json:"Volumes"` - Workdir string `json:"WorkingDir"` - Labels map[string]string `json:"Labels"` + Tty bool + OpenStdin bool + StdinOnce bool + Env []string `json:"Env"` + Cmd []string `json:"Cmd"` + // Healthcheck *HealthConfig + ArgsEscaped bool `json:",omitempty"` + Image string + Volumes map[string]struct{} `json:"Volumes"` + Workdir string `json:"WorkingDir"` + Entrypoint []string `json:"Entrypoint"` + NetworkDisabled bool `json:",omitempty"` + MacAddress string `json:",omitempty"` + OnBuild []string + Labels map[string]string `json:"Labels"` + StopSignal string `json:",omitempty"` + StopTimeout *int `json:",omitempty"` + Shell []string `json:",omitempty"` +} + +func (c ConfigObject) AsList() []string { + return []string{ + fmt.Sprintf("Hostname: %s", c.Hostname), + fmt.Sprintf("Domainname: %s", c.Domainname), + fmt.Sprintf("User: %s", c.User), + fmt.Sprintf("AttachStdin: %t", c.AttachStdin), + fmt.Sprintf("AttachStdout: %t", c.AttachStdout), + fmt.Sprintf("AttachStderr: %t", c.AttachStderr), + fmt.Sprintf("ExposedPorts: %v", sortMap(c.ExposedPorts)), + fmt.Sprintf("Tty: %t", c.Tty), + fmt.Sprintf("OpenStdin: %t", c.OpenStdin), + fmt.Sprintf("StdinOnce: %t", c.StdinOnce), + fmt.Sprintf("Env: %s", strings.Join(c.Env, ",")), + fmt.Sprintf("Cmd: %s", strings.Join(c.Cmd, ",")), + fmt.Sprintf("ArgsEscaped: %t", c.ArgsEscaped), + fmt.Sprintf("Image: %s", c.Image), + fmt.Sprintf("Volumes: %v", sortMap(c.Volumes)), + fmt.Sprintf("Workdir: %s", c.Workdir), + fmt.Sprintf("Entrypoint: %s", strings.Join(c.Entrypoint, ",")), + fmt.Sprintf("NetworkDisabled: %t", c.NetworkDisabled), + fmt.Sprintf("MacAddress: %s", c.MacAddress), + fmt.Sprintf("OnBuild: %s", strings.Join(c.OnBuild, ",")), + fmt.Sprintf("Labels: %v", c.Labels), + fmt.Sprintf("StopSignal: %s", c.StopSignal), + fmt.Sprintf("StopTimeout: %d", c.StopTimeout), + fmt.Sprintf("Shell: %s", strings.Join(c.Shell, ",")), + } } type ConfigSchema struct { @@ -101,13 +150,16 @@ func getImage(p Prepper) (Image, error) { // see if the image name has tag provided, if not add latest as tag - if !HasTag(p.GetSource()) { + if !IsTar(p.GetSource()) && !HasTag(p.GetSource()) { p.SetSource(p.GetSource() + LatestTag) } output.PrintToStdErr("Retrieving image %s from source %s\n", p.GetSource(), p.Name()) imgPath, err := p.GetFileSystem() if err != nil { - return Image{}, err + // return image with FSPath so it can be cleaned up + return Image{ + FSPath: imgPath, + }, err } config, err := p.GetConfig() @@ -140,6 +192,7 @@ if err != nil { return err } + defer imgSrc.Close() img, err := ref.NewImage(nil) if err != nil { return err @@ -220,7 +273,16 @@ if image.FSPath != "" { logrus.Infof("Removing image filesystem directory %s from system", image.FSPath) if err := os.RemoveAll(image.FSPath); err != nil { - logrus.Error(err.Error()) + logrus.Warn(err.Error()) } } } + +func sortMap(m map[string]struct{}) string { + pairs := make([]string, 0) + for key := range m { + pairs = append(pairs, fmt.Sprintf("%s:%s", key, m[key])) + } + sort.Strings(pairs) + return strings.Join(pairs, " ") +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/pkg/util/image_utils.go new/container-diff-0.9.0/pkg/util/image_utils.go --- old/container-diff-0.8.0/pkg/util/image_utils.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/pkg/util/image_utils.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/pkg/util/tar_prepper.go new/container-diff-0.9.0/pkg/util/tar_prepper.go --- old/container-diff-0.8.0/pkg/util/tar_prepper.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/pkg/util/tar_prepper.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/pkg/util/tar_utils.go new/container-diff-0.9.0/pkg/util/tar_utils.go --- old/container-diff-0.8.0/pkg/util/tar_utils.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/pkg/util/tar_utils.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -19,18 +19,25 @@ import ( "archive/tar" "fmt" - "github.com/pkg/errors" - "github.com/sirupsen/logrus" "io" "os" "path/filepath" "strings" + + "github.com/pkg/errors" + "github.com/sirupsen/logrus" ) // Map of target:linkname var hardlinks = make(map[string]string) +type OriginalPerm struct { + path string + perm os.FileMode +} + func unpackTar(tr *tar.Reader, path string, whitelist []string) error { + originalPerms := make([]OriginalPerm, 0) for { header, err := tr.Next() if err == io.EOF { @@ -42,7 +49,7 @@ return err } if strings.Contains(header.Name, ".wh.") { - rmPath := filepath.Join(path, header.Name) + rmPath := filepath.Clean(filepath.Join(path, header.Name)) // Remove the .wh file if it was extracted. if _, err := os.Stat(rmPath); !os.IsNotExist(err) { if err := os.Remove(rmPath); err != nil { @@ -57,7 +64,7 @@ } continue } - target := filepath.Join(path, header.Name) + target := filepath.Clean(filepath.Join(path, header.Name)) // Make sure the target isn't part of the whitelist if checkWhitelist(target, whitelist) { continue @@ -68,6 +75,17 @@ // if its a dir and it doesn't exist create it case tar.TypeDir: if _, err := os.Stat(target); os.IsNotExist(err) { + if mode.Perm()&(1<<(uint(7))) == 0 { + logrus.Debugf("Write permission bit not set on %s by default; setting manually", target) + originalMode := mode + mode = mode | (1 << uint(7)) + // keep track of original file permission to reset later + originalPerms = append(originalPerms, OriginalPerm{ + path: target, + perm: originalMode, + }) + } + logrus.Debugf("Creating directory %s with permissions %v", target, mode) if err := os.MkdirAll(target, mode); err != nil { return err } @@ -96,6 +114,7 @@ } } + logrus.Debugf("Creating file %s with permissions %v", target, mode) currFile, err := os.Create(target) if err != nil { logrus.Errorf("Error creating file %s %s", target, err) @@ -125,7 +144,7 @@ logrus.Errorf("Failed to create symlink between %s and %s: %s", header.Linkname, target, err) } case tar.TypeLink: - linkname := filepath.Join(path, header.Linkname) + linkname := filepath.Clean(filepath.Join(path, header.Linkname)) // Check if the linkname already exists if _, err := os.Stat(linkname); !os.IsNotExist(err) { // If it exists, create the hard link @@ -145,6 +164,13 @@ } } } + + // reset all original file + for _, perm := range originalPerms { + if err := os.Chmod(perm.path, perm.perm); err != nil { + return err + } + } return nil } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/test.sh new/container-diff-0.9.0/test.sh --- old/container-diff-0.8.0/test.sh 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/test.sh 2018-04-10 22:10:52.000000000 +0200 @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright 2016 Google, Inc. All rights reserved. +# Copyright 2018 Google, Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/tests/integration_test.go new/container-diff-0.9.0/tests/integration_test.go --- old/container-diff-0.8.0/tests/integration_test.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/tests/integration_test.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,7 +1,7 @@ // +build integration /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -39,6 +39,9 @@ diffBase = "gcr.io/gcp-runtimes/diff-base" diffModified = "gcr.io/gcp-runtimes/diff-modified" + metadataBase = "gcr.io/gcp-runtimes/metadata-base" + metadataModified = "gcr.io/gcp-runtimes/metadata-modified" + aptBase = "gcr.io/gcp-runtimes/apt-base" aptModified = "gcr.io/gcp-runtimes/apt-modified" @@ -153,6 +156,14 @@ expectedFile: "hist_diff_expected.json", }, { + description: "metadata differ", + subcommand: "diff", + imageA: metadataBase, + imageB: metadataModified, + differFlags: []string{"--type=metadata"}, + expectedFile: "metadata_diff_expected.json", + }, + { description: "apt sorted differ", subcommand: "diff", imageA: aptBase, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/tests/metadata_diff_expected.json new/container-diff-0.9.0/tests/metadata_diff_expected.json --- old/container-diff-0.8.0/tests/metadata_diff_expected.json 1970-01-01 01:00:00.000000000 +0100 +++ new/container-diff-0.9.0/tests/metadata_diff_expected.json 2018-04-10 22:10:52.000000000 +0200 @@ -0,0 +1,19 @@ +[ + { + "Image1": "gcr.io/gcp-runtimes/metadata-base:latest", + "Image2": "gcr.io/gcp-runtimes/metadata-modified:latest", + "DiffType": "Metadata", + "Diff": { + "Adds": [ + "ExposedPorts: 1234/tcp:{}", + "Image: sha256:0b30c570b95ba9cc450c8252cb264a8c66f7492a7dd6fb32f356267b9e04038f", + "Entrypoint: /entrypoint" + ], + "Dels": [ + "ExposedPorts: 1234/tcp:{} 4321/tcp:{}", + "Image: sha256:63d847f046cdda00df8ba9176753059439478784129443dd1da632504dce95bb", + "Entrypoint: " + ] + } + } +] \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/util/analyze_output_utils.go new/container-diff-0.9.0/util/analyze_output_utils.go --- old/container-diff-0.8.0/util/analyze_output_utils.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/util/analyze_output_utils.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/util/diff_output_utils.go new/container-diff-0.9.0/util/diff_output_utils.go --- old/container-diff-0.8.0/util/diff_output_utils.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/util/diff_output_utils.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -172,6 +172,16 @@ return TemplateOutputFromFormat(r, "HistDiff", format) } +type MetadataDiffResult DiffResult + +func (r MetadataDiffResult) OutputStruct() interface{} { + return r +} + +func (r MetadataDiffResult) OutputText(diffType string, format string) error { + return TemplateOutputFromFormat(r, "MetadataDiff", format) +} + type DirDiffResult DiffResult func (r DirDiffResult) OutputStruct() interface{} { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/util/diff_utils.go new/container-diff-0.9.0/util/diff_utils.go --- old/container-diff-0.8.0/util/diff_utils.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/util/diff_utils.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/util/file_cache_test.go new/container-diff-0.9.0/util/file_cache_test.go --- old/container-diff-0.8.0/util/file_cache_test.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/util/file_cache_test.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/util/format_utils.go new/container-diff-0.9.0/util/format_utils.go --- old/container-diff-0.8.0/util/format_utils.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/util/format_utils.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ "SingleVersionPackageDiff": SingleVersionDiffOutput, "MultiVersionPackageDiff": MultiVersionDiffOutput, "HistDiff": HistoryDiffOutput, + "MetadataDiff": MetadataDiffOutput, "DirDiff": FSDiffOutput, "FilenameDiff": FilenameDiffOutput, "ListAnalyze": ListAnalysisOutput, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/util/fs_utils_test.go new/container-diff-0.9.0/util/fs_utils_test.go --- old/container-diff-0.8.0/util/fs_utils_test.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/util/fs_utils_test.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/util/output_sort_utils.go new/container-diff-0.9.0/util/output_sort_utils.go --- old/container-diff-0.8.0/util/output_sort_utils.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/util/output_sort_utils.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/util/output_sort_utils_test.go new/container-diff-0.9.0/util/output_sort_utils_test.go --- old/container-diff-0.8.0/util/output_sort_utils_test.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/util/output_sort_utils_test.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/util/output_text_utils.go new/container-diff-0.9.0/util/output_text_utils.go --- old/container-diff-0.8.0/util/output_text_utils.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/util/output_text_utils.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/util/package_diff_utils.go new/container-diff-0.9.0/util/package_diff_utils.go --- old/container-diff-0.8.0/util/package_diff_utils.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/util/package_diff_utils.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/util/package_diff_utils_test.go new/container-diff-0.9.0/util/package_diff_utils_test.go --- old/container-diff-0.8.0/util/package_diff_utils_test.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/util/package_diff_utils_test.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/util/tar_utils_test.go new/container-diff-0.9.0/util/tar_utils_test.go --- old/container-diff-0.8.0/util/tar_utils_test.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/util/tar_utils_test.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/util/template_utils.go new/container-diff-0.9.0/util/template_utils.go --- old/container-diff-0.8.0/util/template_utils.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/util/template_utils.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -65,6 +65,17 @@ Docker history lines found only in {{.Image2}}:{{if not .Diff.Dels}} None{{else}}{{block "list2" .Diff.Dels}}{{"\n"}}{{range .}}{{print "-" .}}{{"\n"}}{{end}}{{end}}{{end}} ` + +const MetadataDiffOutput = ` +-----{{.DiffType}}----- + +Image metadata differences between {{.Image1}} and {{.Image2}}: + +{{.Image1}}{{if not .Diff.Adds}} None{{else}}{{block "list" .Diff.Adds}}{{"\n"}}{{range .}}{{print "-" .}}{{"\n"}}{{end}}{{end}}{{end}} + +{{.Image2}}{{if not .Diff.Dels}} None{{else}}{{block "list2" .Diff.Dels}}{{"\n"}}{{range .}}{{print "-" .}}{{"\n"}}{{end}}{{end}}{{end}} +` + const FilenameDiffOutput = ` -----Diff of {{.Filename}}----- {{.Description}} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/container-diff-0.8.0/version/version.go new/container-diff-0.9.0/version/version.go --- old/container-diff-0.8.0/version/version.go 2018-03-19 21:25:05.000000000 +0100 +++ new/container-diff-0.9.0/version/version.go 2018-04-10 22:10:52.000000000 +0200 @@ -1,5 +1,5 @@ /* -Copyright 2017 Google, Inc. All rights reserved. +Copyright 2018 Google, Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
