Skip to content
This repository has been archived by the owner on Feb 3, 2023. It is now read-only.

Don't publish private entries #1233

Merged
merged 29 commits into from
Apr 15, 2019
Merged

Don't publish private entries #1233

merged 29 commits into from
Apr 15, 2019

Conversation

struktured
Copy link
Contributor

@struktured struktured commented Apr 8, 2019

Please check one of the following, relating to the CHANGELOG, which should be updated if relevant

  • my changes to the code affect some exposed aspect of the developer experience, and I have added an item to relevant 'Added, Fixed, Changed, Removed, Deprecated, or Security' heading under the 'Unreleased' heading of the CHANGELOG, with the format - summary of change [PR#1234](https://github.com/holochain/holochain-rust/pull/1234)
  • my changes to the code do not affect any exposed aspect of the developer experience

This introduces a fix so that entries defined as being private are not published to the DHT. Currently entry types do not examine there own definitions to ascertain their sharing attribute- this work enhances the publishable logic accordingly.

As this is my first project with the holochain core team, it is requested that reviewers are particularly thorough and stringent before accepting the PR.

Extend EntryType with CanPublish trait

  • Remove can_publish function from existing entry type definition in the core_types crate.
  • Introduce CanPublish trait in core crate which requires a Context to properly determine whether the entry type is sharable.
  • Have EntryType implement new CanPublish trait by extending the entry type functionality in the core crate (even though the EntryType itself is still defined core_types). Most of this commented out code by @lucksus can be probably reused for this purpose.

Rust tests

  • Add test module in core which creates a just complicated enough Context to verify private entries are not published to the DHT. (consider using / extended the existing holochain test library crate).

App-spec tests

functions

  • Make a private entry type called memo to the blog zome which represents private notes and reminders users only write to their local chain. Add public zome functions hash_memo, create_memo, and my_memos.
  • Test that the new entry type is creatable and queryable with aforementioned zome functions.
  • Ensure other users cannot find these entries in their own local chains or the DHT.
  • Test that the chain header still contains the entry address and relevant metadata but without the entry itself. N/A: Considered out of scope for this project

@thedavidmeister
Copy link
Contributor

mmm seems like something we want

Copy link
Member

@zippy zippy left a comment

Choose a reason for hiding this comment

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

The big fix needed is the location of the can_publish check needs to be when a get request is received.

},
EntryValidationData::Delete{old_entry:old_memo,old_entry_header:_,validation_data:_} =>
{
(old_memo.content!="SYS")
Copy link
Member

Choose a reason for hiding this comment

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

This looks weird to me. Why is this here? The system type validation should be internal to holochain, and not happen at the app level I think.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's there cause it's copied from the other zome code of blog zome I believe. So if we question it here we should question it there

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See commit 8d04d68.

CHANGELOG.md Outdated
@@ -50,7 +50,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `add_agent()` admin function now creates keystore file instead of just recording file in config [#1182](https://github.com/holochain/holochain-rust/pull/1182)
- One-time-signing now takes a vector of payloads, and returns a vector of signatures. [#1193](https://github.com/holochain/holochain-rust/pull/1193)
- Pins nixpkgs to Holo-Host channel in shell and CI [#1162](https://github.com/holochain/holochain-rust/pull/1162)
- Uses autodump configuration for pickledb which dumps per change [#1231](https://github.com/holochain/holochain-rust/pull/1231)
Copy link
Member

Choose a reason for hiding this comment

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

Why is the pickledb stuff showing up here?

@@ -10,9 +10,12 @@ use std::{
fmt::{Debug, Error, Formatter},
path::Path,
sync::{Arc, RwLock},
time::Duration,
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure why pickle stuff is at all affected by this PR, looks like files got committed by mistake?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure, either- possibly an awry rebase- will ensure it's clean.

.expect("DNA must be present to test if entry is publishable.");

let entry_type_name = self.to_string();
context.log(format!("got entry type name of {}", entry_type_name));
Copy link
Member

Choose a reason for hiding this comment

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

It looks like this logging should probably be removed and was for debugging? or needs a "debug/" prefix

core/src/entry/mod.rs Outdated Show resolved Hide resolved
core/src/entry/mod.rs Outdated Show resolved Hide resolved
core/src/workflows/get_entry_result.rs Outdated Show resolved Hide resolved
))
));

match entry_result.clone() {
Copy link
Member

Choose a reason for hiding this comment

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

This is happening in the wrong place. What's going on here is that if you got the value across the network, you simply aren't returning it to the caller. But that means that you actually got a value that should never have been released to you. This check needs to happen by the receiver of the get request. i.e. in handle_fetch_entry and handle_fetch_entry_result so that it never leaves the source machine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See commit 8dd9f9e.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@zippy you mentioned handle_fetch_entry and handle_fetch_entry_result- are both required to check can_publish? I only added it for handle_fetch_entry and it worked with my tests at least. Please confirm desired behavior for handle_fetch_entry_result.

@@ -65,7 +65,7 @@ DHTs enable key/value pair storage and retrieval across many machines. The only

In fact, since many DHTs are used for illegal file sharing (Napster, Bittorrent, Sharezaa, etc.), they are designed to protect anonymity of uploaders so they won't get in trouble. File sharing DHTs frequently serve virus infected files, planted by uploaders trying to infect digital pirates. There's no accountability for actions or reliable way to ensure bad data doesn't spread.
Copy link
Member

Choose a reason for hiding this comment

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

This file also shouldn't show up as changed in this PR right?

@struktured
Copy link
Contributor Author

struktured commented Apr 12, 2019 via email

@struktured struktured changed the title WIP: Don't publish private entries Don't publish private entries Apr 13, 2019
Copy link
Member

@zippy zippy left a comment

Choose a reason for hiding this comment

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

Woot woot! Looks great. Nice work.

Copy link
Collaborator

@lucksus lucksus left a comment

Choose a reason for hiding this comment

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

👏 👏 👏

@lucksus lucksus merged commit 5548511 into develop Apr 15, 2019
@zippy zippy deleted the dont-publish-private-entries branch October 4, 2019 18:36
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.

7 participants