Skip to content

Commit

Permalink
chore: dev environment QoL updates (#339)
Browse files Browse the repository at this point in the history
* chore: change unnecessary sync+restart to bind mount

* chore: more comprehensive watch rebuild rules

* chore: watch will now trigger rebuilds on any config file changes, while leaving HMR in tact

* chore: add config option for startup wait period enablement (only affects BHE right now)
  • Loading branch information
superlinkx authored Jan 24, 2024
1 parent 9f517b2 commit c97bf69
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 54 deletions.
53 changes: 27 additions & 26 deletions cmd/api/src/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,32 +139,33 @@ type DefaultAdminConfiguration struct {
}

type Configuration struct {
Version int `json:"version"`
BindAddress string `json:"bind_addr"`
NetTimeoutSeconds int `json:"net_timeout_seconds"`
SlowQueryThreshold int64 `json:"slow_query_threshold"`
MaxGraphQueryCacheSize int `json:"max_graphdb_cache_size"`
MaxAPICacheSize int `json:"max_api_cache_size"`
MetricsPort string `json:"metrics_port"`
RootURL serde.URL `json:"root_url"`
WorkDir string `json:"work_dir"`
LogLevel string `json:"log_level"`
LogPath string `json:"log_path"`
TLS TLSConfiguration `json:"tls"`
GraphDriver string `json:"graph_driver"`
Database DatabaseConfiguration `json:"database"`
Neo4J DatabaseConfiguration `json:"neo4j"`
Crypto CryptoConfiguration `json:"crypto"`
SAML SAMLConfiguration `json:"saml"`
SpecterAuth SpecterAuthConfiguration `json:"specter_auth"`
DefaultAdmin DefaultAdminConfiguration `json:"default_admin"`
CollectorsBasePath string `json:"collectors_base_path"`
DatapipeInterval int `json:"datapipe_interval"`
EnableAPILogging bool `json:"enable_api_logging"`
DisableAnalysis bool `json:"disable_analysis"`
DisableCypherQC bool `json:"disable_cypher_qc"`
DisableMigrations bool `json:"disable_migrations"`
TraversalMemoryLimit uint16 `json:"traversal_memory_limit"`
Version int `json:"version"`
BindAddress string `json:"bind_addr"`
NetTimeoutSeconds int `json:"net_timeout_seconds"`
SlowQueryThreshold int64 `json:"slow_query_threshold"`
MaxGraphQueryCacheSize int `json:"max_graphdb_cache_size"`
MaxAPICacheSize int `json:"max_api_cache_size"`
MetricsPort string `json:"metrics_port"`
RootURL serde.URL `json:"root_url"`
WorkDir string `json:"work_dir"`
LogLevel string `json:"log_level"`
LogPath string `json:"log_path"`
TLS TLSConfiguration `json:"tls"`
GraphDriver string `json:"graph_driver"`
Database DatabaseConfiguration `json:"database"`
Neo4J DatabaseConfiguration `json:"neo4j"`
Crypto CryptoConfiguration `json:"crypto"`
SAML SAMLConfiguration `json:"saml"`
SpecterAuth SpecterAuthConfiguration `json:"specter_auth"`
DefaultAdmin DefaultAdminConfiguration `json:"default_admin"`
CollectorsBasePath string `json:"collectors_base_path"`
DatapipeInterval int `json:"datapipe_interval"`
EnableStartupWaitPeriod bool `json:"enable_startup_wait_period"`
EnableAPILogging bool `json:"enable_api_logging"`
DisableAnalysis bool `json:"disable_analysis"`
DisableCypherQC bool `json:"disable_cypher_qc"`
DisableMigrations bool `json:"disable_migrations"`
TraversalMemoryLimit uint16 `json:"traversal_memory_limit"`
}

func (s Configuration) TempDirectory() string {
Expand Down
44 changes: 23 additions & 21 deletions cmd/api/src/config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package config

import (
"fmt"

"github.com/specterops/bloodhound/dawgs/drivers/neo4j"

"github.com/specterops/bloodhound/src/serde"
Expand All @@ -33,27 +34,28 @@ func NewDefaultConfiguration() (Configuration, error) {
return Configuration{}, fmt.Errorf("failed to generate default password: %w", err)
} else {
return Configuration{
Version: 0,
BindAddress: "127.0.0.1",
NetTimeoutSeconds: 70, // Default timeout to avoid race conditions with 60 second gateway timeouts
SlowQueryThreshold: 100, // Threshold in ms for caching queries
MaxGraphQueryCacheSize: 100, // Number of cache items for graph queries
MaxAPICacheSize: 200, // Number of cache items for API utilities
MetricsPort: ":2112",
RootURL: serde.MustParseURL("http://localhost"),
WorkDir: "/opt/bhe/work",
LogLevel: "INFO",
LogPath: DefaultLogFilePath,
CollectorsBasePath: "/etc/bloodhound/collectors",
DatapipeInterval: 60,
EnableAPILogging: true,
DisableAnalysis: false,
DisableCypherQC: false,
DisableMigrations: false,
TraversalMemoryLimit: 2, // 2 GiB by default
TLS: TLSConfiguration{},
SAML: SAMLConfiguration{},
GraphDriver: neo4j.DriverName, // Default to Neo4j as the graph driver
Version: 0,
BindAddress: "127.0.0.1",
NetTimeoutSeconds: 70, // Default timeout to avoid race conditions with 60 second gateway timeouts
SlowQueryThreshold: 100, // Threshold in ms for caching queries
MaxGraphQueryCacheSize: 100, // Number of cache items for graph queries
MaxAPICacheSize: 200, // Number of cache items for API utilities
MetricsPort: ":2112",
RootURL: serde.MustParseURL("http://localhost"),
WorkDir: "/opt/bhe/work",
LogLevel: "INFO",
LogPath: DefaultLogFilePath,
CollectorsBasePath: "/etc/bloodhound/collectors",
DatapipeInterval: 60,
EnableStartupWaitPeriod: true,
EnableAPILogging: true,
DisableAnalysis: false,
DisableCypherQC: false,
DisableMigrations: false,
TraversalMemoryLimit: 2, // 2 GiB by default
TLS: TLSConfiguration{},
SAML: SAMLConfiguration{},
GraphDriver: neo4j.DriverName, // Default to Neo4j as the graph driver
Database: DatabaseConfiguration{
MaxConcurrentSessions: 10,
},
Expand Down
1 change: 1 addition & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ services:
- traefik.http.routers.bhui.service=bhui
- traefik.http.services.bhui.loadbalancer.server.port=3000
volumes:
- ./cmd/ui/public:/bloodhound/cmd/ui/public:ro
- ./cmd/ui/src:/bloodhound/cmd/ui/src:ro
- ./packages/javascript/bh-shared-ui/src:/bloodhound/packages/javascript/bh-shared-ui/src:ro
- ./packages/javascript/js-client-library/src:/bloodhound/packages/javascript/js-client-library/src:ro
Expand Down
26 changes: 19 additions & 7 deletions docker-compose.watch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,26 @@ services:
bh-ui:
develop:
watch:
- action: sync+restart
path: cmd/ui/public
target: /bloodhound/cmd/ui/public
- action: rebuild
path: package.json
path: ./.yarnrc.yml
- action: rebuild
path: cmd/ui/package.json
path: ./package.json
- action: rebuild
path: packages/javascript
path: ./cmd/ui
ignore:
- node_modules
- node_modules
- src
- public
- dist
- action: rebuild
path: ./packages/javascript/bh-shared-ui
ignore:
- node_modules
- dist
- src
- action: rebuild
path: ./packages/javascript/js-client-library
ignore:
- node_modules
- dist
- src

0 comments on commit c97bf69

Please sign in to comment.