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

Merge snapshot module and create_layout module into one #49

Merged
merged 4 commits into from
Jan 27, 2021

Conversation

SolidifiedRay
Copy link
Contributor

In PR #46, @IshaDave and I created a new module called before_after_filesystem_snapshot.py. This module returns a 'snapshot' of a file structure showing which files were unchanged, modified, added, or removed. It also includes a function that generates material rules and product rules based on this snapshot.

In this PR, I move the functions from before_after_filesystem_snapshot.py to create_layout.py. The create_layout.py will now utilize the snapshot function to generate more complex material rules and product rules, including MATCH, ALLOW, MODIFY, DELETE, CREATE, DISALLOW.

You can also read issue #48 for more ideas.

create_layout.py Outdated Show resolved Hide resolved
create_layout.py Outdated Show resolved Hide resolved
create_layout.py Outdated Show resolved Hide resolved
create_layout.py Outdated Show resolved Hide resolved
@adityasaky
Copy link
Member

cc @lukpueh could you take a look at this? 😄

Copy link
Member

@lukpueh lukpueh left a comment

Choose a reason for hiding this comment

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

Thanks for working on this, @SolidifiedRay! It would be really great if your commit history made it clearer, what parts of the PR are renames (e.g. test_before_after_filesystem_snapshot.py --> test_create_layout.py ), or copy-pasting entire functions from one module to another (e.g. the snapshot function), and what changes/adds functionality (e.g. the create_layout.create_*_rules functions work differently now and there also seem to be new tests). Do you think you can redraw the git history?

Our commits guideline document has a corresponding paragraph. It also has some good recommendations for commit messages. ;)

@SolidifiedRay
Copy link
Contributor Author

SolidifiedRay commented Aug 27, 2020

Do you think you can redraw the git history?

Yes, I will do this. Thanks for pointing this out!

Copy link
Member

@adityasaky adityasaky left a comment

Choose a reason for hiding this comment

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

This is looking pretty good, @SolidifiedRay! Just some thoughts on how we can simplify the APIs further. 😄

create_layout.py Outdated Show resolved Hide resolved
create_layout.py Outdated Show resolved Hide resolved
create_layout.py Outdated Show resolved Hide resolved
create_layout.py Outdated Show resolved Hide resolved
create_layout.py Outdated Show resolved Hide resolved
Copy link
Member

@adityasaky adityasaky left a comment

Choose a reason for hiding this comment

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

Solid work, @SolidifiedRay! This is looking pretty good. I quite like the tests you have, and the PR needs a few mostly straightforward changes IMO.

.travis.yml Show resolved Hide resolved
create_layout.py Outdated Show resolved Hide resolved
create_layout.py Outdated Show resolved Hide resolved
create_layout.py Outdated Show resolved Hide resolved
create_layout.py Outdated Show resolved Hide resolved
create_layout.py Outdated Show resolved Hide resolved
create_layout.py Outdated Show resolved Hide resolved
tests/test_create_layout.py Outdated Show resolved Hide resolved
tests/test_create_layout.py Outdated Show resolved Hide resolved
@SolidifiedRay
Copy link
Contributor Author

Thanks a lot for the review @adityasaky ! I have made most of the changes but I still have some questions and I have replied to your review.

Copy link
Member

@adityasaky adityasaky left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @SolidifiedRay!

cc @lukpueh any thoughts?

create_layout.py Outdated Show resolved Hide resolved
Copy link
Member

@lukpueh lukpueh left a comment

Choose a reason for hiding this comment

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

Excellent work, @SolidifiedRay and 💯 for extensive testing!! At first I thought I'd only point out some minor style nits, but looking at the tests I did find some interesting issues with the rule creation functions (which is good!! :).

So it seems like we need to be more careful, when an artifact qualifies for multiple rules (see inline comments in tests).

create_layout.py Outdated Show resolved Hide resolved
create_layout.py Outdated Show resolved Hide resolved
create_layout.py Outdated Show resolved Hide resolved
create_layout.py Outdated Show resolved Hide resolved
create_layout.py Outdated Show resolved Hide resolved
tests/test_create_layout.py Show resolved Hide resolved
tests/test_create_layout.py Outdated Show resolved Hide resolved
['MATCH', 'bar/bat/four.tgz', 'WITH', 'PRODUCTS', 'FROM', 'first_step'],
['MATCH', 'one.tgz', 'WITH', 'PRODUCTS', 'FROM', 'first_step'],
['MATCH', 'foo/two.tgz', 'WITH', 'PRODUCTS', 'FROM', 'first_step'],
['MATCH', 'three.txt', 'WITH', 'PRODUCTS', 'FROM', 'first_step'],
Copy link
Member

Choose a reason for hiding this comment

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

Ha! This is rather interesting. Like above, this rule makes the subsequent 'DELETE' rule moot. But unlike above, both rules here are actually meaningful. We should document this issue and add it to the list of artifact rule discussion items in in-toto/specification#4. (cc @SantiagoTorres)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks again for pointing this interesting problem out!
For this problem, I believe the DELETE rule is more important. I think a malicious artifact won't cause many problems if we are going to delete it. But I also believe it is important to let the user know that something wrong happened in the supply chain if there is a mismatch of the artifact.

Copy link
Member

Choose a reason for hiding this comment

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

So you say, if an artifact gets deleted in one step, it doesn't really matter if it matched the product from a previous step? That's an interesting thought, and I do agree with you on a practical level.

However, I still think it is a lot more important to guarantee the integrity of artifacts in transit between steps than within a step. Because I trust the functionary more than the man in the middle. So I would say, match rules across steps should always be prioritized.

Moreover, a DISALLOW * in the products rules of a step could catch any artifact that was expected to be deleted but wasn't actually deleted.

@SolidifiedRay, would you mind filing an issue on in-toto/docs for this, and see if you can find other such conflicting rules too? Let's discuss this with other in-toto folks there before make a decision here. In the meanwhile we can just warn the caller about these cases and suggest to manually review.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure! Here is the link: issue#41.

Copy link
Member

Choose a reason for hiding this comment

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

Excellent write-up of the issue. Thanks, a lot!

tests/test_create_layout.py Outdated Show resolved Hide resolved
tests/test_create_layout.py Outdated Show resolved Hide resolved
@SolidifiedRay
Copy link
Contributor Author

Thanks a ton for the review! @lukpueh I have fixed most of the nits that you mentioned. The issue related to the rule creation function is interesting, and I left some ideas under your comments. Could you please check on it? Thanks!

create_layout.py Outdated Show resolved Hide resolved
create_layout.py Outdated Show resolved Hide resolved
@lukpueh
Copy link
Member

lukpueh commented Nov 9, 2020

Thanks for addressing all my comments, and for sharing your suggestions about conflicting rules, @SolidifiedRay! As said above, I think we don't need to find a solution here. Let's just add a warning about the conflict so that we can move forward here.

create_layout.py Outdated Show resolved Hide resolved
create_layout.py Outdated Show resolved Hide resolved
create_layout.py Outdated Show resolved Hide resolved
create_layout.py Outdated Show resolved Hide resolved
@SolidifiedRay
Copy link
Contributor Author

I have reimplemented the sort and added a warning about the rule conflict. I really appreciate your code review all the time. Thanks! @lukpueh

create_layout.py Outdated Show resolved Hide resolved
@SolidifiedRay SolidifiedRay changed the base branch from develop to dependabot/npm_and_yarn/lodash-4.17.19 December 7, 2020 05:05
@SolidifiedRay SolidifiedRay changed the base branch from dependabot/npm_and_yarn/lodash-4.17.19 to develop December 7, 2020 05:05
…eate_layout.py

Move snapshot function from before_after_filesystem_snapshot.py to create_laytou.py and remove before_after_filesystem_snapshot.py.
This snapshot function will be used to enhance the rules generation function in create_layout.py.
create_layout.py Outdated Show resolved Hide resolved
@lukpueh
Copy link
Member

lukpueh commented Jan 18, 2021

Apart from a tiny nit (see review above) this looks really good. Thanks for your persistence, @SolidifiedRay!

@IshaDave, I'd love if you could do some user testing here. Ideally while (re-)creating the layout for the task you are working on (in-toto/in-toto#278). :)

- Rename snapshot() function to changes_between_snapshots()
- Generate DELETE, MODIFY, and CREATE rules generation
- For MATCH rules, match only those that already were in the previous step, and allow the rest by name
- Add test_create_material_rules_with_zero_index
- Add test_create_material_rules_with_nonzero_index
- Add test_create_product_rules
Copy link
Member

@lukpueh lukpueh left a comment

Choose a reason for hiding this comment

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

🎉

@lukpueh lukpueh merged commit 22a0eb9 into in-toto:develop Jan 27, 2021
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.

4 participants