Skip to content

Commit

Permalink
Merge branch 'main' into BED-4020
Browse files Browse the repository at this point in the history
  • Loading branch information
rvazarkar authored Jan 25, 2024
2 parents c5a6e02 + 7dea7cd commit cd53a6f
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 22 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/static-code-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright 2024 Specter Ops, Inc.
#
# Licensed under the Apache License, Version 2.0
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

name: Static Code Analysis

on:
push:
branches: [main]
pull_request:
types: [opened, synchronize]


jobs:
run-analysis:
runs-on: ubuntu-latest

steps:
- name: Checkout source code for this repository
uses: actions/checkout@v3

- name: Install Go
uses: actions/setup-go@v4
with:
go-version: '^1.21.0'

- name: Install Node
uses: actions/setup-node@v4
with:
node-version: 18

- name: Install Yarn
run: |
npm install --global yarn
- name: Run Analysis
run: |
go run github.com/specterops/bloodhound/packages/go/stbernard analysis
28 changes: 16 additions & 12 deletions .golangci.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,18 @@
"max-same-issues": 0,
"exclude-rules": [
{
"path": "hyperloglog_bench_test\\.go",
"text": "SA6002:"
"path": ".go",
"text": "((neo4j(.+)(NewDriver|Result))|Id|database.Database|(.+)Deprecated) is deprecated"
},
{
"path": "cache_test\\.go",
"text": "SA1026:"
"text": "SA1026:",
"severity": "warning"
},
{
"path": "foldr_test\\.go",
"text": "SA4000:"
},
{
"path": ".go",
"text": "((neo4j(.+)(NewDriver|Result))|Id|database.Database|(.+)Deprecated) is deprecated"
},
{
"path": "expected_ingest.go",
"text": "ST1022:"
"text": "SA4000:",
"severity": "warning"
}
]
},
Expand All @@ -50,6 +44,16 @@
{
"text": "(ST\\d{4}|S\\d{4}|SA1019)",
"severity": "warning"
},
{
"path": "hyperloglog_bench_test\\.go",
"text": "SA6002:",
"severity": "warning"
},
{
"path": "expected_ingest.go",
"text": "ST1022:",
"severity": "warning"
}
]
},
Expand Down
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"go.testEnvVars": {
"INTEGRATION_CONFIG_PATH": "${workspaceFolder}/local-harnesses/integration.config.json"
},
"go.formatTool": "goimports",
"go.lintTool": "golangci-lint",
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
},
Expand Down
4 changes: 4 additions & 0 deletions cmd/api/src/analysis/ad/adcs_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ func TestADCSESC6a(t *testing.T) {
certTemplates, err := ad2.FetchNodesByKind(context.Background(), db, ad.CertTemplate)
require.Nil(t, err)
domains, err := ad2.FetchNodesByKind(context.Background(), db, ad.Domain)
require.Nil(t, err)

cache := ad2.NewADCSCache()
cache.BuildCache(context.Background(), db, enterpriseCertAuthorities, certTemplates)
Expand Down Expand Up @@ -714,6 +715,7 @@ func TestADCSESC6a(t *testing.T) {
certTemplates, err := ad2.FetchNodesByKind(context.Background(), db, ad.CertTemplate)
require.Nil(t, err)
domains, err := ad2.FetchNodesByKind(context.Background(), db, ad.Domain)
require.Nil(t, err)

cache := ad2.NewADCSCache()
cache.BuildCache(context.Background(), db, enterpriseCertAuthorities, certTemplates)
Expand Down Expand Up @@ -768,6 +770,7 @@ func TestADCSESC6a(t *testing.T) {
certTemplates, err := ad2.FetchNodesByKind(context.Background(), db, ad.CertTemplate)
require.Nil(t, err)
domains, err := ad2.FetchNodesByKind(context.Background(), db, ad.Domain)
require.Nil(t, err)

cache := ad2.NewADCSCache()
cache.BuildCache(context.Background(), db, enterpriseCertAuthorities, certTemplates)
Expand Down Expand Up @@ -826,6 +829,7 @@ func TestADCSESC6a(t *testing.T) {
certTemplates, err := ad2.FetchNodesByKind(context.Background(), db, ad.CertTemplate)
require.Nil(t, err)
domains, err := ad2.FetchNodesByKind(context.Background(), db, ad.Domain)
require.Nil(t, err)

cache := ad2.NewADCSCache()
cache.BuildCache(context.Background(), db, enterpriseCertAuthorities, certTemplates)
Expand Down
18 changes: 17 additions & 1 deletion docker-compose.watch.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Copyright 2024 Specter Ops, Inc.
#
# Licensed under the Apache License, Version 2.0
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

version: '3'

services:
Expand Down Expand Up @@ -26,4 +42,4 @@ services:
ignore:
- node_modules
- dist
- src
- src
12 changes: 3 additions & 9 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,9 @@ prune-my-branches nuclear='no':
echo "Remaining Git Branches:"
git --no-pager branch
# run linting for all Go modules
go-lint:
#!/usr/bin/env bash
echo 'ensuring golangci-lint@{{golangci-lint-version}} is installed'
go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@{{golangci-lint-version}}
echo 'running golangci-lint on all detected modules in your go.work'
# grab all the module locations from go.work and run golangci-lint on each
golangci-lint run $(cat go.work | { cat | grep -E '\./' | awk 'NF{print $0 "/..."}'; } | tr '\n' ' ')
echo 'done'
# Run all analyzers (requires jq to be installed locally)
analyze:
go run github.com/specterops/bloodhound/packages/go/stbernard analysis | jq 'sort_by(.severity) | .[] | {"severity": .severity, "description": .description, "location": "\(.location.path):\(.location.lines.begin)"}'

# run docker compose commands for the BH dev profile (Default: up)
bh-dev *ARGS='up':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ export const AllEdgeTypes: Category[] = [
ActiveDirectoryRelationshipKind.GoldenCert,
ActiveDirectoryRelationshipKind.ADCSESC1,
ActiveDirectoryRelationshipKind.ADCSESC3,
ActiveDirectoryRelationshipKind.ADCSESC6a,
ActiveDirectoryRelationshipKind.ADCSESC9a,
],
},
],
Expand Down

0 comments on commit cd53a6f

Please sign in to comment.