{"action":"created","comment":{"url":"https://api.github.com/repos/facebook/osquery/pulls/comments/208659357","pull_request_review_id":144515139,"id":208659357,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwODY1OTM1Nw==","diff_hunk":"@@ -11,114 +11,130 @@\n #pragma once\n \n #include <mutex>\n-#include <set>\n #include <string>\n #include <vector>\n \n #include <boost/noncopyable.hpp>\n #include <boost/tokenizer.hpp>\n+#include <boost/utility/string_view.hpp>\n \n #include <osquery/core.h>\n #include <osquery/filesystem.h>\n \n namespace osquery {\n \n /**\n- * @brief multiset based implementation for path search.\n+ * @brief Vector based implemention for path search.\n  *\n- * 'multiset' is used because with patterns we can serach for equivalent keys.\n- * Since  '/This/Path/is' ~= '/This/Path/%' ~= '/This/Path/%%' (equivalent).\n+ * PathSet applies the following policy -\n+ * patternedPath -    Path can contain pattern '%' and '%%'.\n+ *                    Path components containing partial patterns are also\n+ *                    supported e.g. '/This/Path/xyz%' or '/This/Path/%xyz'\n+ *                    or '/This/Path/%xyz%' but '/This/Path/xy%z'\n+ *                    is not supported i.e. 'xy%z' is considered as normal\n+ *                    string.\n  *\n- * multiset is protected by lock. It is threadsafe.\n- *\n- * PathSet can take any of the two policies -\n- * 1. patternedPath - Path can contain pattern '%' and '%%'.\n- *                    Path components containing only '%' and '%%' are supported\n- *                    e.g. '/This/Path/%'.\n- *                    Path components containing partial patterns are not\n- *                    supported e.g. '/This/Path/xyz%' ('xyz%' will not be\n- *                    treated as pattern).\n  */\n template <typename PathType>\n class PathSet : private boost::noncopyable {\n  public:\n   void insert(const std::string& str) {\n     auto pattern = str;\n     replaceGlobWildcards(pattern);\n-    auto vpath = PathType::createVPath(pattern);\n+    auto path = PathType::createPath(std::move(pattern));\n \n     WriteLock lock(mset_lock_);\n-    for (auto& path : vpath) {\n-      paths_.insert(std::move(path));\n-    }\n+    patterns_.push_back(std::move(path));\n   }\n \n   bool find(const std::string& str) const {\n     auto path = PathType::createPath(str);\n \n     ReadLock lock(mset_lock_);\n-    if (paths_.find(path) != paths_.end()) {\n-      return true;\n+    for (auto& pattern : patterns_) {\n+      if (compare(pattern, path)) {\n+        return true;\n+      }\n     }\n     return false;\n   }\n \n   void clear() {\n     WriteLock lock(mset_lock_);\n-    paths_.clear();\n+    patterns_.clear();\n   }\n \n   bool empty() const {\n     ReadLock lock(mset_lock_);\n-    return paths_.empty();\n+    return patterns_.empty();\n   }\n \n  private:\n   typedef typename PathType::Path Path;\n   typedef typename PathType::Compare Compare;\n-  std::multiset<Path, Compare> paths_;\n+  std::vector<Path> patterns_;\n   mutable Mutex mset_lock_;\n+  Compare compare;\n };\n \n class patternedPath {\n  public:\n   typedef boost::tokenizer<boost::char_separator<char>> tokenizer;\n   typedef std::vector<std::string> Path;\n-  typedef std::vector<Path> VPath;\n   struct Compare {\n+    bool compareStrings(boost::string_view vlhs,","path":"osquery/events/pathset.h","position":98,"original_position":98,"commit_id":"cb708e128c014958eb51e2563d5a462cdf1d83a2","original_commit_id":"cb708e128c014958eb51e2563d5a462cdf1d83a2","user":{"login":"npamnani","id":16044266,"node_id":"MDQ6VXNlcjE2MDQ0MjY2","avatar_url":"https://avatars2.githubusercontent.com/u/16044266?v=4","gravatar_id":"","url":"https://api.github.com/users/npamnani","html_url":"https://github.com/npamnani","followers_url":"https://api.github.com/users/npamnani/followers","following_url":"https://api.github.com/users/npamnani/following{/other_user}","gists_url":"https://api.github.com/users/npamnani/gists{/gist_id}","starred_url":"https://api.github.com/users/npamnani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/npamnani/subscriptions","organizations_url":"https://api.github.com/users/npamnani/orgs","repos_url":"https://api.github.com/users/npamnani/repos","events_url":"https://api.github.com/users/npamnani/events{/privacy}","received_events_url":"https://api.github.com/users/npamnani/received_events","type":"User","site_admin":false},"body":"It for the performance reason, with string_view it is just pointer manipulation underneath unlike std::string where sub-strings get  generated.","created_at":"2018-08-08T17:01:35Z","updated_at":"2018-08-08T17:01:35Z","html_url":"https://github.com/facebook/osquery/pull/4839#discussion_r208659357","pull_request_url":"https://api.github.com/repos/facebook/osquery/pulls/4839","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/facebook/osquery/pulls/comments/208659357"},"html":{"href":"https://github.com/facebook/osquery/pull/4839#discussion_r208659357"},"pull_request":{"href":"https://api.github.com/repos/facebook/osquery/pulls/4839"}},"in_reply_to_id":208624722},"pull_request":{"url":"https://api.github.com/repos/facebook/osquery/pulls/4839","id":207027132,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA3MDI3MTMy","html_url":"https://github.com/facebook/osquery/pull/4839","diff_url":"https://github.com/facebook/osquery/pull/4839.diff","patch_url":"https://github.com/facebook/osquery/pull/4839.patch","issue_url":"https://api.github.com/repos/facebook/osquery/issues/4839","number":4839,"state":"open","locked":false,"title":"Changing algorithm of pathset to support more patterns","user":{"login":"npamnani","id":16044266,"node_id":"MDQ6VXNlcjE2MDQ0MjY2","avatar_url":"https://avatars2.githubusercontent.com/u/16044266?v=4","gravatar_id":"","url":"https://api.github.com/users/npamnani","html_url":"https://github.com/npamnani","followers_url":"https://api.github.com/users/npamnani/followers","following_url":"https://api.github.com/users/npamnani/following{/other_user}","gists_url":"https://api.github.com/users/npamnani/gists{/gist_id}","starred_url":"https://api.github.com/users/npamnani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/npamnani/subscriptions","organizations_url":"https://api.github.com/users/npamnani/orgs","repos_url":"https://api.github.com/users/npamnani/repos","events_url":"https://api.github.com/users/npamnani/events{/privacy}","received_events_url":"https://api.github.com/users/npamnani/received_events","type":"User","site_admin":false},"body":"Matching wildcard rules for exclude path -\r\n\r\n%: Match all files and folders for one level.\r\n%%: Match all files and folders recursively.\r\n%abc: Match all within-level ending in \"abc\".\r\nabc%: Match all within-level starting with \"abc\".\r\n%abc%: Match all within-level containing sub-string \"abc\" anywhere.\r\n\r\nThis patch fixes https://github.com/facebook/osquery/issues/3692 and https://github.com/facebook/osquery/issues/4750\r\n\r\nPaying my technical debt :)\r\n","created_at":"2018-08-08T14:27:42Z","updated_at":"2018-08-08T17:01:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"47853b3381ad6566cdfd511f1e51f47c0f43c0c7","assignee":{"login":"guliashvili","id":4594711,"node_id":"MDQ6VXNlcjQ1OTQ3MTE=","avatar_url":"https://avatars3.githubusercontent.com/u/4594711?v=4","gravatar_id":"","url":"https://api.github.com/users/guliashvili","html_url":"https://github.com/guliashvili","followers_url":"https://api.github.com/users/guliashvili/followers","following_url":"https://api.github.com/users/guliashvili/following{/other_user}","gists_url":"https://api.github.com/users/guliashvili/gists{/gist_id}","starred_url":"https://api.github.com/users/guliashvili/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guliashvili/subscriptions","organizations_url":"https://api.github.com/users/guliashvili/orgs","repos_url":"https://api.github.com/users/guliashvili/repos","events_url":"https://api.github.com/users/guliashvili/events{/privacy}","received_events_url":"https://api.github.com/users/guliashvili/received_events","type":"User","site_admin":false},"assignees":[{"login":"guliashvili","id":4594711,"node_id":"MDQ6VXNlcjQ1OTQ3MTE=","avatar_url":"https://avatars3.githubusercontent.com/u/4594711?v=4","gravatar_id":"","url":"https://api.github.com/users/guliashvili","html_url":"https://github.com/guliashvili","followers_url":"https://api.github.com/users/guliashvili/followers","following_url":"https://api.github.com/users/guliashvili/following{/other_user}","gists_url":"https://api.github.com/users/guliashvili/gists{/gist_id}","starred_url":"https://api.github.com/users/guliashvili/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guliashvili/subscriptions","organizations_url":"https://api.github.com/users/guliashvili/orgs","repos_url":"https://api.github.com/users/guliashvili/repos","events_url":"https://api.github.com/users/guliashvili/events{/privacy}","received_events_url":"https://api.github.com/users/guliashvili/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":196858822,"node_id":"MDU6TGFiZWwxOTY4NTg4MjI=","url":"https://api.github.com/repos/facebook/osquery/labels/cla%20signed","name":"cla signed","color":"ededed","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/facebook/osquery/pulls/4839/commits","review_comments_url":"https://api.github.com/repos/facebook/osquery/pulls/4839/comments","review_comment_url":"https://api.github.com/repos/facebook/osquery/pulls/comments{/number}","comments_url":"https://api.github.com/repos/facebook/osquery/issues/4839/comments","statuses_url":"https://api.github.com/repos/facebook/osquery/statuses/cb708e128c014958eb51e2563d5a462cdf1d83a2","head":{"label":"npamnani:path_set_enhancement","ref":"path_set_enhancement","sha":"cb708e128c014958eb51e2563d5a462cdf1d83a2","user":{"login":"npamnani","id":16044266,"node_id":"MDQ6VXNlcjE2MDQ0MjY2","avatar_url":"https://avatars2.githubusercontent.com/u/16044266?v=4","gravatar_id":"","url":"https://api.github.com/users/npamnani","html_url":"https://github.com/npamnani","followers_url":"https://api.github.com/users/npamnani/followers","following_url":"https://api.github.com/users/npamnani/following{/other_user}","gists_url":"https://api.github.com/users/npamnani/gists{/gist_id}","starred_url":"https://api.github.com/users/npamnani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/npamnani/subscriptions","organizations_url":"https://api.github.com/users/npamnani/orgs","repos_url":"https://api.github.com/users/npamnani/repos","events_url":"https://api.github.com/users/npamnani/events{/privacy}","received_events_url":"https://api.github.com/users/npamnani/received_events","type":"User","site_admin":false},"repo":{"id":138294636,"node_id":"MDEwOlJlcG9zaXRvcnkxMzgyOTQ2MzY=","name":"osquery","full_name":"npamnani/osquery","owner":{"login":"npamnani","id":16044266,"node_id":"MDQ6VXNlcjE2MDQ0MjY2","avatar_url":"https://avatars2.githubusercontent.com/u/16044266?v=4","gravatar_id":"","url":"https://api.github.com/users/npamnani","html_url":"https://github.com/npamnani","followers_url":"https://api.github.com/users/npamnani/followers","following_url":"https://api.github.com/users/npamnani/following{/other_user}","gists_url":"https://api.github.com/users/npamnani/gists{/gist_id}","starred_url":"https://api.github.com/users/npamnani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/npamnani/subscriptions","organizations_url":"https://api.github.com/users/npamnani/orgs","repos_url":"https://api.github.com/users/npamnani/repos","events_url":"https://api.github.com/users/npamnani/events{/privacy}","received_events_url":"https://api.github.com/users/npamnani/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/npamnani/osquery","description":"SQL powered operating system instrumentation, monitoring, and analytics.","fork":true,"url":"https://api.github.com/repos/npamnani/osquery","forks_url":"https://api.github.com/repos/npamnani/osquery/forks","keys_url":"https://api.github.com/repos/npamnani/osquery/keys{/key_id}","collaborators_url":"https://api.github.com/repos/npamnani/osquery/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/npamnani/osquery/teams","hooks_url":"https://api.github.com/repos/npamnani/osquery/hooks","issue_events_url":"https://api.github.com/repos/npamnani/osquery/issues/events{/number}","events_url":"https://api.github.com/repos/npamnani/osquery/events","assignees_url":"https://api.github.com/repos/npamnani/osquery/assignees{/user}","branches_url":"https://api.github.com/repos/npamnani/osquery/branches{/branch}","tags_url":"https://api.github.com/repos/npamnani/osquery/tags","blobs_url":"https://api.github.com/repos/npamnani/osquery/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/npamnani/osquery/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/npamnani/osquery/git/refs{/sha}","trees_url":"https://api.github.com/repos/npamnani/osquery/git/trees{/sha}","statuses_url":"https://api.github.com/repos/npamnani/osquery/statuses/{sha}","languages_url":"https://api.github.com/repos/npamnani/osquery/languages","stargazers_url":"https://api.github.com/repos/npamnani/osquery/stargazers","contributors_url":"https://api.github.com/repos/npamnani/osquery/contributors","subscribers_url":"https://api.github.com/repos/npamnani/osquery/subscribers","subscription_url":"https://api.github.com/repos/npamnani/osquery/subscription","commits_url":"https://api.github.com/repos/npamnani/osquery/commits{/sha}","git_commits_url":"https://api.github.com/repos/npamnani/osquery/git/commits{/sha}","comments_url":"https://api.github.com/repos/npamnani/osquery/comments{/number}","issue_comment_url":"https://api.github.com/repos/npamnani/osquery/issues/comments{/number}","contents_url":"https://api.github.com/repos/npamnani/osquery/contents/{+path}","compare_url":"https://api.github.com/repos/npamnani/osquery/compare/{base}...{head}","merges_url":"https://api.github.com/repos/npamnani/osquery/merges","archive_url":"https://api.github.com/repos/npamnani/osquery/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/npamnani/osquery/downloads","issues_url":"https://api.github.com/repos/npamnani/osquery/issues{/number}","pulls_url":"https://api.github.com/repos/npamnani/osquery/pulls{/number}","milestones_url":"https://api.github.com/repos/npamnani/osquery/milestones{/number}","notifications_url":"https://api.github.com/repos/npamnani/osquery/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/npamnani/osquery/labels{/name}","releases_url":"https://api.github.com/repos/npamnani/osquery/releases{/id}","deployments_url":"https://api.github.com/repos/npamnani/osquery/deployments","created_at":"2018-06-22T11:25:33Z","updated_at":"2018-06-22T11:25:38Z","pushed_at":"2018-08-08T14:17:50Z","git_url":"git://github.com/npamnani/osquery.git","ssh_url":"git@github.com:npamnani/osquery.git","clone_url":"https://github.com/npamnani/osquery.git","svn_url":"https://github.com/npamnani/osquery","homepage":"https://osquery.io","size":15687,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"facebook:master","ref":"master","sha":"a8418314939333c0e6286688a5a2507e9d062b72","user":{"login":"facebook","id":69631,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY5NjMx","avatar_url":"https://avatars3.githubusercontent.com/u/69631?v=4","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"repo":{"id":22394357,"node_id":"MDEwOlJlcG9zaXRvcnkyMjM5NDM1Nw==","name":"osquery","full_name":"facebook/osquery","owner":{"login":"facebook","id":69631,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY5NjMx","avatar_url":"https://avatars3.githubusercontent.com/u/69631?v=4","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/facebook/osquery","description":"SQL powered operating system instrumentation, monitoring, and analytics.","fork":false,"url":"https://api.github.com/repos/facebook/osquery","forks_url":"https://api.github.com/repos/facebook/osquery/forks","keys_url":"https://api.github.com/repos/facebook/osquery/keys{/key_id}","collaborators_url":"https://api.github.com/repos/facebook/osquery/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/facebook/osquery/teams","hooks_url":"https://api.github.com/repos/facebook/osquery/hooks","issue_events_url":"https://api.github.com/repos/facebook/osquery/issues/events{/number}","events_url":"https://api.github.com/repos/facebook/osquery/events","assignees_url":"https://api.github.com/repos/facebook/osquery/assignees{/user}","branches_url":"https://api.github.com/repos/facebook/osquery/branches{/branch}","tags_url":"https://api.github.com/repos/facebook/osquery/tags","blobs_url":"https://api.github.com/repos/facebook/osquery/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/facebook/osquery/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/facebook/osquery/git/refs{/sha}","trees_url":"https://api.github.com/repos/facebook/osquery/git/trees{/sha}","statuses_url":"https://api.github.com/repos/facebook/osquery/statuses/{sha}","languages_url":"https://api.github.com/repos/facebook/osquery/languages","stargazers_url":"https://api.github.com/repos/facebook/osquery/stargazers","contributors_url":"https://api.github.com/repos/facebook/osquery/contributors","subscribers_url":"https://api.github.com/repos/facebook/osquery/subscribers","subscription_url":"https://api.github.com/repos/facebook/osquery/subscription","commits_url":"https://api.github.com/repos/facebook/osquery/commits{/sha}","git_commits_url":"https://api.github.com/repos/facebook/osquery/git/commits{/sha}","comments_url":"https://api.github.com/repos/facebook/osquery/comments{/number}","issue_comment_url":"https://api.github.com/repos/facebook/osquery/issues/comments{/number}","contents_url":"https://api.github.com/repos/facebook/osquery/contents/{+path}","compare_url":"https://api.github.com/repos/facebook/osquery/compare/{base}...{head}","merges_url":"https://api.github.com/repos/facebook/osquery/merges","archive_url":"https://api.github.com/repos/facebook/osquery/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/facebook/osquery/downloads","issues_url":"https://api.github.com/repos/facebook/osquery/issues{/number}","pulls_url":"https://api.github.com/repos/facebook/osquery/pulls{/number}","milestones_url":"https://api.github.com/repos/facebook/osquery/milestones{/number}","notifications_url":"https://api.github.com/repos/facebook/osquery/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/facebook/osquery/labels{/name}","releases_url":"https://api.github.com/repos/facebook/osquery/releases{/id}","deployments_url":"https://api.github.com/repos/facebook/osquery/deployments","created_at":"2014-07-29T20:27:33Z","updated_at":"2018-08-08T15:58:32Z","pushed_at":"2018-08-08T15:58:23Z","git_url":"git://github.com/facebook/osquery.git","ssh_url":"git@github.com:facebook/osquery.git","clone_url":"https://github.com/facebook/osquery.git","svn_url":"https://github.com/facebook/osquery","homepage":"https://osquery.io","size":15686,"stargazers_count":12907,"watchers_count":12907,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1523,"mirror_url":null,"archived":false,"open_issues_count":280,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":1523,"open_issues":280,"watchers":12907,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/facebook/osquery/pulls/4839"},"html":{"href":"https://github.com/facebook/osquery/pull/4839"},"issue":{"href":"https://api.github.com/repos/facebook/osquery/issues/4839"},"comments":{"href":"https://api.github.com/repos/facebook/osquery/issues/4839/comments"},"review_comments":{"href":"https://api.github.com/repos/facebook/osquery/pulls/4839/comments"},"review_comment":{"href":"https://api.github.com/repos/facebook/osquery/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/facebook/osquery/pulls/4839/commits"},"statuses":{"href":"https://api.github.com/repos/facebook/osquery/statuses/cb708e128c014958eb51e2563d5a462cdf1d83a2"}},"author_association":"NONE"}}
{"actor":{"display_login":"npamnani"}}