Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Refuse to download OSTree targets with the fake/binary package manager. #1653

Merged
merged 1 commit into from
Apr 28, 2020

Conversation

pattivacek
Copy link
Collaborator

Previously the download would succeed due to the empty length but the installation would fail. Better to fail as early as possible.

@codecov-io
Copy link

codecov-io commented Apr 23, 2020

Codecov Report

Merging #1653 into master will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1653      +/-   ##
==========================================
+ Coverage   82.74%   82.76%   +0.02%     
==========================================
  Files         191      191              
  Lines       12085    12089       +4     
==========================================
+ Hits        10000    10006       +6     
+ Misses       2085     2083       -2     
Impacted Files Coverage Δ
src/libaktualizr/uptane/tuf.h 95.96% <ø> (ø)
...libaktualizr/package_manager/packagemanagerfake.cc 92.06% <100.00%> (+0.39%) ⬆️
src/libaktualizr/uptane/tuf.cc 91.25% <100.00%> (+0.03%) ⬆️
src/libaktualizr/package_manager/ostreemanager.cc 79.04% <0.00%> (-1.48%) ⬇️
src/libaktualizr/storage/sqlstorage.cc 80.13% <0.00%> (+0.19%) ⬆️
src/libaktualizr/primary/sotauptaneclient.cc 90.94% <0.00%> (+0.23%) ⬆️
src/libaktualizr/storage/sqlstorage_base.cc 81.63% <0.00%> (+1.36%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 20c88a8...2fe1cb6. Read the comment docs.

@pattivacek pattivacek force-pushed the fix/abort-ostree-with-fake-pacman branch 2 times, most recently from 9177703 to c8459e7 Compare April 23, 2020 07:56
@@ -110,5 +110,10 @@ bool PackageManagerFake::fetchTarget(const Uptane::Target& target, Uptane::Fetch
return false;
}

if (target.IsOstree()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably prefer something like if (target.type_ != this->type_), but that should be also good for now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me too, but for now we don't expose package manager types... unless I've forgotten something?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we don't. I just was thinking that we might want to do something like this in the future,

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PackageManagerInterface::name() is kind of a package manager type :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mike-sul True, but it still doesn't have 1:1 match with update type.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I know, maybe adding something like package_manager->isTargetSupported(const Target&) (or logicalEcu->isTargetSupported()) so the pack manager implementation decides whether it can handle the given target or not would be the best here.

@@ -135,6 +135,7 @@ Target::Target(std::string filename, EcuMap ecus, std::vector<Hash> hashes, uint
correlation_id_(std::move(correlation_id)) {
// sort hashes so that higher priority hash algorithm goes first
std::sort(hashes_.begin(), hashes_.end(), [](const Hash &l, const Hash &r) { return l.type() < r.type(); });
type_ = "binary";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, it is better to set to "unknown"? I also think that "BINARY" is capitalized, though you can never be sure. Should we use .toLower()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, it is better to set to "unknown"?

Agreed, done.

I also think that "BINARY" is capitalized, though you can never be sure. Should we use .toLower()?

We don't appear to use "BINARY"; the only comparison we use for Target types is with "OSTREE". I think for now the comparison is fine as is.

Previously the download would succeed due to the empty length but the
installation would fail. Better to fail as early as possible.

Signed-off-by: Patrick Vacek <patrickvacek@gmail.com>
@pattivacek pattivacek force-pushed the fix/abort-ostree-with-fake-pacman branch from c8459e7 to 2fe1cb6 Compare April 28, 2020 12:20
@pattivacek pattivacek merged commit d81e2c5 into master Apr 28, 2020
@pattivacek pattivacek deleted the fix/abort-ostree-with-fake-pacman branch April 28, 2020 12:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants