Precommit hooks: General payload integrity checking. #14

Merged
merged 1 commit into from Oct 5, 2016

Conversation

Projects
None yet
6 participants
Contributor

eriksoe commented Jul 8, 2011

Added precommit hooks compares the body-length / body-checksum / gzip integrity against expected values.

Owner

krestenkrab commented on cb93594 Jul 8, 2011

This is run before riak_object:apply_updates afaik, shouldn't you then use get_update_metadata in stead of get_metadata? Otherwise you would be checking what was previously stored as far as I can see.

Contributor

PharkMillups commented Jul 13, 2011

Hey Erik,

Thanks for sending this over. In addition to what Kresten suggested, do you have a few minutes to add a description page for this? Have a look at the "function-contrib-gollum" directory for examples.

Thanks again.

Mark

I checked the cod ein put_fsm, and updates are applied before the hook is called; so I was wrong.

+precommit_verify_cksum({fail,_}=Error) -> Error;
+precommit_verify_cksum(Object) ->
+ case get_usermeta(<<"Content-MD5">>, Object) of
+ error -> Object; % No checksum.
@seancribbs

seancribbs Feb 24, 2012

Contributor

Tabs vs. spaces makes this look weird. Please use 4 spaces.

+ error -> Object; % No size.
+ {ok, ExpectedSize} ->
+ Contents = riak_object:get_value(Object),
+ ActualSize = list_to_binary(integer_to_list(byte_size(Contents))),
@seancribbs

seancribbs Feb 24, 2012

Contributor

I would actually do this the other way, converting the incoming meta into an integer. Stylistic difference, I guess.

+uncompress(Method, _CompData) ->
+ error(format("unknown compression method: ~s", [Method])).
+
+inflate(CompData) ->
@seancribbs

seancribbs Feb 24, 2012

Contributor

Why not use zlib:uncompress/1 or zlib:unzip/1?

Contributor

seancribbs commented Feb 24, 2012

As @PharkMillups said, a description page (as well as fixes or responses to the comments made on the code) is all this needs to be merged.

Contributor

eriksoe commented Mar 2, 2012

It's on my backlog... :-)

@bsparrow435 bsparrow435 merged commit 0ec4dd9 into basho:master Oct 5, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment