Skip to content

Commit 463872c

Browse files
scudettesnyk-bot
andauthored
Sync 0.6.6 branch to master (#2054)
* [Snyk] Upgrade ace-builds from 1.9.3 to 1.9.5 (#2037) fix: upgrade ace-builds from 1.9.3 to 1.9.5 Snyk has created this PR to upgrade ace-builds from 1.9.3 to 1.9.5. See this package in npm: https://www.npmjs.com/package/ace-builds See this project in Snyk: https://app.snyk.io/org/scudette/project/76f4d127-566b-42ef-86f4-bdcbc92b90b4?utm_source=github&utm_medium=referral&page=upgrade-pr * Added Send to CyberChef context menu on table cells. (#2039) * Made context menus settable in the config file (#2040) Added more context targets: - VirusTotal - Google - CyberChef * Updated themes for context menu (#2041) Added "Clipboard" target * Added org_delete() function to remove orgs. (#2042) * Org manager maintains services lifetime (#2045) * Pass org ids in href parameters (#2047) Usually OrgId is passed in headers but we do have some href links so we need to also support passing the org id in query parameters. * collect each query's status separately (#2049) When dealing with multiple queries per collection it is important to keep stats on each query separately to get more accurate picture of what happened. For example one artifact may collect successfuly and another may fail. This change also fixes a bug where the execution duration was sometimes counted twice for queries that failed because they send an error as well as a completion message. * Split server sanity checks into root org and other orgs (#2052) The sanity checker ensured the server is running in a sane state. It also starts things like initial server artifacts etc. This PR split sanity checks to run on the root org (i.e. once when the server is started) and on each org. For example the initial server artifacts are only run on the root org and not on other orgs. Added org rm command * Fixed CSS for column selector ui (#2053) * Prepare for 0.6.6 release Co-authored-by: Snyk bot <[email protected]>
1 parent edc1369 commit 463872c

File tree

108 files changed

+3469
-2258
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+3469
-2258
lines changed

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
all:
22
go run make.go -v autoDev
33

4+
assets:
5+
go run make.go -v assets
6+
47
auto:
58
go run make.go -v auto
69

accessors/file_store/fixtures/TestGlob.golden

-4
This file was deleted.

accessors/file_store/fs.go

-77
This file was deleted.

accessors/file_store/fs_test.go

-75
This file was deleted.

acls/roles.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66

77
acl_proto "www.velocidex.com/golang/velociraptor/acls/proto"
88
config_proto "www.velocidex.com/golang/velociraptor/config/proto"
9+
"www.velocidex.com/golang/velociraptor/utils"
910
)
1011

1112
func ValidateRole(role string) bool {
@@ -97,7 +98,7 @@ func GetRolePermissions(
9798

9899
// An administrator for the root org is allowed to
99100
// manipulate orgs.
100-
if config_obj != nil && config_obj.OrgId == "" {
101+
if config_obj != nil && utils.IsRootOrg(config_obj.OrgId) {
101102
result.OrgAdmin = true
102103
}
103104

api/api.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import (
5656
"www.velocidex.com/golang/velociraptor/paths"
5757
"www.velocidex.com/golang/velociraptor/server"
5858
"www.velocidex.com/golang/velociraptor/services"
59+
"www.velocidex.com/golang/velociraptor/utils"
5960
vql_subsystem "www.velocidex.com/golang/velociraptor/vql"
6061
"www.velocidex.com/golang/velociraptor/vql/acl_managers"
6162
"www.velocidex.com/golang/vfilter"
@@ -433,7 +434,7 @@ func (self *ApiServer) GetUserUITraits(
433434
result.Orgs = user_info.Orgs
434435

435436
for _, item := range result.Orgs {
436-
if item.Id == "" {
437+
if utils.IsRootOrg(item.Id) {
437438
item.Name = "<root>"
438439
item.Id = "root"
439440
}
@@ -449,6 +450,7 @@ func (self *ApiServer) GetUserUITraits(
449450
result.InterfaceTraits.DefaultPassword = user_options.DefaultPassword
450451
result.InterfaceTraits.DefaultDownloadsLock = user_options.DefaultDownloadsLock
451452
result.InterfaceTraits.Customizations = user_options.Customizations
453+
result.InterfaceTraits.Links = user_options.Links
452454
}
453455

454456
return result, nil

api/assets.go

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ func GetTemplateHandler(
8989
BasePath: base,
9090
Heading: "Heading",
9191
UserTheme: user_options.Theme,
92+
OrgId: user_options.Org,
9293
}
9394
err = tmpl.Execute(w, args)
9495
if err != nil {

api/auth.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,7 @@ func NewDefaultUserObject(config_obj *config_proto.Config) *api_proto.ApiUser {
3030

3131
if config_obj.GUI != nil {
3232
result.InterfaceTraits = &api_proto.ApiUserInterfaceTraits{
33-
Links: []*api_proto.UILink{},
34-
}
35-
36-
for _, link := range config_obj.GUI.Links {
37-
result.InterfaceTraits.Links = append(result.InterfaceTraits.Links,
38-
&api_proto.UILink{Text: link.Text, Url: link.Url})
33+
Links: config_obj.GUI.Links,
3934
}
4035
}
4136

api/authenticators/orgs.go

+29-8
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,44 @@ package authenticators
33
import (
44
"errors"
55
"net/http"
6+
"net/url"
67

78
"www.velocidex.com/golang/velociraptor/acls"
89
api_proto "www.velocidex.com/golang/velociraptor/api/proto"
910
"www.velocidex.com/golang/velociraptor/services"
1011
)
1112

12-
func CheckOrgAccess(r *http.Request, user_record *api_proto.VelociraptorUser) error {
13+
func GetOrgIdFromRequest(r *http.Request) string {
14+
// Now we have to determine which org the user wants to use. First
15+
// let's check if the user specified an org in the header.
16+
org_id := r.Header.Get("Grpc-Metadata-Orgid")
17+
if org_id != "" {
18+
return org_id
19+
}
1320

14-
// Now we have to determine which org the user wants to
15-
// use. First let's check if the user specified an org in the
16-
// header.
17-
org_id := "root"
18-
current_orgid_array := r.Header.Get("Grpc-Metadata-Orgid")
19-
if len(current_orgid_array) == 1 {
20-
org_id = string(current_orgid_array[0])
21+
// Maybe the org id is specified in the URL itself. We allow
22+
// the org id to be specified as a query string in order to
23+
// support plain href links. However ultimately the GRPC
24+
// gateway needs to check the org id in a header - so if an
25+
// org is specified using a query string and NOT specified
26+
// using a header, we set the header from it for further
27+
// checks by the GRPC layer (in services/users/grpc.go)
28+
q, err := url.ParseQuery(r.URL.RawQuery)
29+
if err == nil {
30+
org_id = q.Get("org_id")
31+
if org_id != "" {
32+
r.Header.Set("Grpc-Metadata-Orgid", org_id)
33+
return org_id
34+
}
2135
}
2236

37+
org_id = "root"
38+
r.Header.Set("Grpc-Metadata-Orgid", org_id)
39+
return org_id
40+
}
41+
42+
func CheckOrgAccess(r *http.Request, user_record *api_proto.VelociraptorUser) error {
43+
org_id := GetOrgIdFromRequest(r)
2344
err := _checkOrgAccess(r, org_id, user_record)
2445
if err == nil {
2546
return nil

0 commit comments

Comments
 (0)