Skip to content

Commit

Permalink
Improved eslint score (Velocidex#2642)
Browse files Browse the repository at this point in the history
Also added DELETE_RESULTS permissions to allow finer control over who
can delete results.
  • Loading branch information
scudette authored Apr 25, 2023
1 parent 4b5d2fd commit 3c0b3f1
Show file tree
Hide file tree
Showing 111 changed files with 630 additions and 481 deletions.
7 changes: 7 additions & 0 deletions acls/acls.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ const (
// Allowed to create zip files.
PREPARE_RESULTS

// Allowed to delete results from the server
DELETE_RESULTS

// Allowed raw datastore access
DATASTORE_ACCESS

Expand Down Expand Up @@ -171,6 +174,8 @@ func (self ACL_PERMISSION) String() string {
return "MACHINE_STATE"
case PREPARE_RESULTS:
return "PREPARE_RESULTS"
case DELETE_RESULTS:
return "DELETE_RESULTS"
case DATASTORE_ACCESS:
return "DATASTORE_ACCESS"

Expand Down Expand Up @@ -221,6 +226,8 @@ func GetPermission(name string) ACL_PERMISSION {
return MACHINE_STATE
case "PREPARE_RESULTS":
return PREPARE_RESULTS
case "DELETE_RESULTS":
return DELETE_RESULTS
case "DATASTORE_ACCESS":
return DATASTORE_ACCESS

Expand Down
40 changes: 25 additions & 15 deletions acls/proto/acl.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions acls/proto/acl.proto
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ message ApiClientACL {
bool filesystem_write = 14;
bool machine_state = 16;
bool prepare_results = 17;
bool delete_results = 23;
bool datastore_access = 18;

// A list of roles in lieu of the permissions above. These will be
Expand Down
8 changes: 8 additions & 0 deletions acls/roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var (
"FILESYSTEM_WRITE",
"MACHINE_STATE",
"PREPARE_RESULTS",
"DELETE_RESULTS",
"DATASTORE_ACCESS",
}
)
Expand Down Expand Up @@ -101,6 +102,10 @@ func DescribePermissions(token *acl_proto.ApiClientACL) []string {
result = append(result, "PREPARE_RESULTS")
}

if token.DeleteResults {
result = append(result, "DELETE_RESULTS")
}

if token.DatastoreAccess {
result = append(result, "DATASTORE_ACCESS")
}
Expand Down Expand Up @@ -148,6 +153,8 @@ func SetTokenPermission(
token.MachineState = true
case "PREPARE_RESULTS":
token.PrepareResults = true
case "DELETE_RESULTS":
token.DeleteResults = true
case "DATASTORE_ACCESS":
token.DatastoreAccess = true

Expand Down Expand Up @@ -188,6 +195,7 @@ func GetRolePermissions(
result.FilesystemWrite = true
result.MachineState = true
result.PrepareResults = true
result.DeleteResults = true

// An administrator for the root org is allowed to
// manipulate orgs.
Expand Down
2 changes: 1 addition & 1 deletion api/filesearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func newMatcher(term, search_type string) (matcher, error) {
return &literal_matcher{[]byte(term)}, nil

case "regex":
re, err := regexp.Compile("(?i)" + term)
re, err := regexp.Compile("(?ism)" + term)
if err != nil {
return nil, err
}
Expand Down
28 changes: 14 additions & 14 deletions api/proto/api.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions artifacts/testdata/server/testcases/orgs.out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ SELECT Name, OrgId FROM orgs() ORDER BY OrgId[
"filesystem_read": true,
"filesystem_write": true,
"machine_state": true,
"prepare_results": true
"prepare_results": true,
"delete_results": true
}
},
{
Expand Down Expand Up @@ -89,7 +90,8 @@ SELECT Name, OrgId FROM orgs() ORDER BY OrgId[
"filesystem_read": true,
"filesystem_write": true,
"machine_state": true,
"prepare_results": true
"prepare_results": true,
"delete_results": true
}
},
{
Expand Down Expand Up @@ -161,7 +163,8 @@ SELECT Name, OrgId FROM orgs() ORDER BY OrgId[
"filesystem_read": true,
"filesystem_write": true,
"machine_state": true,
"prepare_results": true
"prepare_results": true,
"delete_results": true
}
},
{
Expand Down Expand Up @@ -214,7 +217,8 @@ SELECT Name, OrgId FROM orgs() ORDER BY OrgId[
"filesystem_read": true,
"filesystem_write": true,
"machine_state": true,
"prepare_results": true
"prepare_results": true,
"delete_results": true
}
},
{
Expand Down Expand Up @@ -284,7 +288,8 @@ SELECT Name, OrgId FROM orgs() ORDER BY OrgId[
"filesystem_read": true,
"filesystem_write": true,
"machine_state": true,
"prepare_results": true
"prepare_results": true,
"delete_results": true
}
},
{
Expand Down
6 changes: 4 additions & 2 deletions artifacts/testdata/server/testcases/users.out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ SELECT whoami() FROM scope()[
"filesystem_read": true,
"filesystem_write": true,
"machine_state": true,
"prepare_results": true
"prepare_results": true,
"delete_results": true
}
}
]SELECT user_delete(user="TestUser", really_do_it=TRUE) FROM scope()[
Expand Down Expand Up @@ -149,7 +150,8 @@ SELECT whoami() FROM scope()[
"filesystem_read": true,
"filesystem_write": true,
"machine_state": true,
"prepare_results": true
"prepare_results": true,
"delete_results": true
}
}
]SELECT user_delete(user="TestUser", really_do_it=TRUE, orgs="ORGID2") FROM scope()[
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ require (
www.velocidex.com/golang/go-prefetch v0.0.0-20220801101854-338dbe61982a
www.velocidex.com/golang/oleparse v0.0.0-20230217092320-383a0121aafe
www.velocidex.com/golang/regparser v0.0.0-20221020153526-bbc758cbd18b
www.velocidex.com/golang/vfilter v0.0.0-20230413031155-cadd50f14c5d
www.velocidex.com/golang/vfilter v0.0.0-20230425012353-b6d0a982ca34
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,7 @@ www.velocidex.com/golang/oleparse v0.0.0-20230217092320-383a0121aafe/go.mod h1:R
www.velocidex.com/golang/regparser v0.0.0-20221020153526-bbc758cbd18b h1:NrnjFXwjUi7vdLEDKgSxu6cs304UJLZE/H7pSXXakVA=
www.velocidex.com/golang/regparser v0.0.0-20221020153526-bbc758cbd18b/go.mod h1:pxSECT5mWM3goJ4sxB4HCJNKnKqiAlpyT8XnvBwkLGU=
www.velocidex.com/golang/vfilter v0.0.0-20220103082604-85bb38175cb7/go.mod h1:eEFMhAmoFHWGCKF39j+iOhTH8REpqBndc3OsdPsxqo8=
www.velocidex.com/golang/vfilter v0.0.0-20230413031155-cadd50f14c5d h1:4CIkMbS48+qG/Dhaziskfxlb6FyQ8PxL3KpquQQuNnM=
www.velocidex.com/golang/vfilter v0.0.0-20230413031155-cadd50f14c5d/go.mod h1:4mDQuvnVu6oPvDu/rZm8eYXh0h8mM7j9CJpj1nRfu8g=
www.velocidex.com/golang/vfilter v0.0.0-20230425012353-b6d0a982ca34 h1:Ww5wvoiNEzTzsGffZsCkc2uIwk1hAJJdNZcLHU7Ogsg=
www.velocidex.com/golang/vfilter v0.0.0-20230425012353-b6d0a982ca34/go.mod h1:4mDQuvnVu6oPvDu/rZm8eYXh0h8mM7j9CJpj1nRfu8g=
www.velocidex.com/golang/vtypes v0.0.0-20220816192452-6a27ae078f12 h1:8azOLd/l6sPy1/ug03ueA7jLfsVwE1sI3oHg9q/nkqQ=
www.velocidex.com/golang/vtypes v0.0.0-20220816192452-6a27ae078f12/go.mod h1:gpuRaiyhcuPmZYvI/zw+rjlDXklR2ORaLQBuzCXe84o=
10 changes: 9 additions & 1 deletion gui/velociraptor/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
module.exports = {
env: { browser: true, node: true },
env: {
browser: true,
node: true,
es6: true,
},
parser: "@babel/eslint-parser",
parserOptions: {
requireConfigFile: false,
Expand Down Expand Up @@ -31,5 +35,9 @@ module.exports = {
rules: {
// allows characters like <'`&^"
"react/no-unescaped-entities": 0,
"no-extra-semi": 0,
"react/display-name": 0,
"no-empty": 0,
"no-unused-vars": ["error", { "args": "none" }],
},
};
Loading

0 comments on commit 3c0b3f1

Please sign in to comment.