Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

santa-driver: add an acknowledge feature to allow timeouts #220

Merged
merged 5 commits into from Jan 26, 2018

Conversation

tburgin
Copy link
Member

@tburgin tburgin commented Nov 27, 2017

  • lost requests will be retried
  • acknowledged requests will wait forever for a response - only large binaries generate an acknowledgement

@google google deleted a comment from googlebot Jan 24, 2018
/**
While waiting for a response from the daemon, this is the maximum number cache checks before
re-sending the request.
*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

indent -1

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -144,6 +144,12 @@ class SantaDecisionManager : public OSObject {
*/
static const uint32_t kRequestLoopSleepMilliseconds = 1000;

/**
While waiting for a response from the daemon, this is the maximum number cache checks before
re-sending the request.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Indent both lines +2

Copy link
Member Author

Choose a reason for hiding this comment

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

+1 Done.

} while (return_action == ACTION_REQUEST_BINARY && ClientConnected());
if (return_action == ACTION_REQUEST_BINARY) ++cache_check_count;
} while ((return_action == ACTION_REQUEST_BINARY || return_action == ACTION_RESPOND_ACK)
&& ClientConnected() && cache_check_count < kRequestCacheChecks);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the condition here can include the cache_check_count increment too without being less clear. Maybe this:

} while (ClientConnected() &&
         ((return_action == ACTION_REQUEST_BINARY && ++cache_check_count < kRequestCacheChecks) ||
          (return_action == ACTION_RESPOND_ACK)));

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that's nicer. Except the || is over 100 lines :(

case ACTION_RESPOND_ALLOW:
case ACTION_RESPOND_DENY:
decision_cache->set(
identifier, val, ((uint64_t)ACTION_REQUEST_BINARY << 56));
if (decision_cache->set(identifier, val, ((uint64_t)ACTION_REQUEST_BINARY << 56))) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add a TODO above this line to make calling set twice unnecessary - having both calls will involve finding and locking the bucket (or buckets) multiple times.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@@ -38,6 +38,8 @@
#import "SNTStoredEvent.h"
#import "SNTSyncdQueue.h"

static size_t kLargeBinarySize = 30 * 1024 * 1024;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add a brief comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@@ -239,6 +242,18 @@ - (void)beginListening {
} else if (strncmp("/bin/cat", vdata.path, strlen("/bin/cat")) == 0) {
[self postToKernelAction:ACTION_RESPOND_ALLOW forVnodeID:vdata.vnode_id];
self.timesSeenCat++;
} else if (strncmp("/usr/bin/cal", vdata.path, strlen("/usr/bin/cal")) == 0) {
static int count;
Copy link
Collaborator

Choose a reason for hiding this comment

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

init to 0

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@googlebot
Copy link
Collaborator

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this State. It's up to you to confirm consent of the commit author(s) and merge this pull request when appropriate.

Copy link
Member Author

@tburgin tburgin left a comment

Choose a reason for hiding this comment

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

PTAL

case ACTION_RESPOND_ALLOW:
case ACTION_RESPOND_DENY:
decision_cache->set(
identifier, val, ((uint64_t)ACTION_REQUEST_BINARY << 56));
if (decision_cache->set(identifier, val, ((uint64_t)ACTION_REQUEST_BINARY << 56))) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

} while (return_action == ACTION_REQUEST_BINARY && ClientConnected());
if (return_action == ACTION_REQUEST_BINARY) ++cache_check_count;
} while ((return_action == ACTION_REQUEST_BINARY || return_action == ACTION_RESPOND_ACK)
&& ClientConnected() && cache_check_count < kRequestCacheChecks);
Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that's nicer. Except the || is over 100 lines :(

@@ -144,6 +144,12 @@ class SantaDecisionManager : public OSObject {
*/
static const uint32_t kRequestLoopSleepMilliseconds = 1000;

/**
While waiting for a response from the daemon, this is the maximum number cache checks before
re-sending the request.
Copy link
Member Author

Choose a reason for hiding this comment

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

+1 Done.

/**
While waiting for a response from the daemon, this is the maximum number cache checks before
re-sending the request.
*/
Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -38,6 +38,8 @@
#import "SNTStoredEvent.h"
#import "SNTSyncdQueue.h"

static size_t kLargeBinarySize = 30 * 1024 * 1024;
Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@@ -239,6 +242,18 @@ - (void)beginListening {
} else if (strncmp("/bin/cat", vdata.path, strlen("/bin/cat")) == 0) {
[self postToKernelAction:ACTION_RESPOND_ALLOW forVnodeID:vdata.vnode_id];
self.timesSeenCat++;
} else if (strncmp("/usr/bin/cal", vdata.path, strlen("/usr/bin/cal")) == 0) {
static int count;
Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@tburgin tburgin merged commit 0e6eb45 into google:master Jan 26, 2018
dskfh pushed a commit to dskfh/santa that referenced this pull request Jul 17, 2020
* santa-driver: Add an acknowledge feature to allow timeouts for lost requests

* project: cocoapods 1.3.1 update

* review updates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants