Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/workflows/nginx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Nginx Config

# Validates app/nginx.conf via scripts/validate-nginx.sh (single source of truth,
# also run locally). `nginx -t` syntax errors block; gixy security findings are
# advisory (surfaced as a warning), mirroring the Trivy pattern in docker.yml.

on:
workflow_dispatch:
inputs:
reason:
description: 'Optional reason for manual run'
required: false
default: 'manual trigger'
push:
branches: ["main", "develop", "release/*"]
paths:
- 'app/nginx.conf'
- 'app/Dockerfile' # script auto-detects the pinned nginx image from here
- 'scripts/validate-nginx.sh'
- '.github/workflows/nginx.yml'
pull_request:
branches: ["main", "develop", "release/*"]
paths:
- 'app/nginx.conf'
- 'app/Dockerfile'
- 'scripts/validate-nginx.sh'
- '.github/workflows/nginx.yml'

permissions: read-all

jobs:
validate:
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false

# validate-nginx.sh exit codes:
# 0 ok | 1 syntax fail | 2 missing prereq | 3 gixy findings | 4 gixy could not run
# We block on syntax/prereq (1/2) and on gixy failing to run (4 — a scan that
# never executed must not pass silently). Only real gixy findings (3) are
# downgraded to an advisory warning, mirroring docker.yml's Trivy pattern.
- name: Validate nginx config (syntax blocking, gixy advisory)
run: |
set +e
./scripts/validate-nginx.sh
code=$?
set -e
case "${code}" in
0) echo "nginx config valid and clean" ;;
3) echo "::warning title=gixy::nginx security findings (advisory) — see log above" ;;
4) echo "::error title=gixy::gixy could not run — scan did not execute"; exit 1 ;;
*) exit "${code}" ;;
esac
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ blocklists/.env
libs/vendor
tests/docker_logs
.qodo
.nginx-validate.*
2 changes: 2 additions & 0 deletions api/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"time"

"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/compress"
"github.com/gofiber/fiber/v2/middleware/healthcheck"
"github.com/gofiber/fiber/v2/middleware/helmet"
"github.com/gofiber/fiber/v2/middleware/limiter"
Expand Down Expand Up @@ -69,6 +70,7 @@ func NewServer(config *config.Config, service service.Service, db db.Db, cache c
func (s *APIServer) setupMiddlewares() {
s.App.Use(middleware.SentryFiber())
s.App.Use(middleware.Recover())
s.App.Use(compress.New(compress.Config{Level: compress.LevelBestSpeed}))
s.App.Use(requestid.New())
s.App.Use(logger.New(logger.Config{
Next: func(c *fiber.Ctx) bool {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"dropIndexes": "profiles",
"index": "account_id"
}
]
12 changes: 12 additions & 0 deletions api/db/mongodb/migrations/018_profiles_account_id_index.up.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[{
"createIndexes": "profiles",
"indexes": [
{
"key": {
"account_id": 1
},
"name": "account_id",
"background": true
}
]
}]
3 changes: 0 additions & 3 deletions api/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2553,9 +2553,6 @@ const docTemplate = `{
"items": {
"type": "string"
}
},
"queries": {
"type": "integer"
}
}
},
Expand Down
3 changes: 0 additions & 3 deletions api/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2545,9 +2545,6 @@
"items": {
"type": "string"
}
},
"queries": {
"type": "integer"
}
}
},
Expand Down
2 changes: 0 additions & 2 deletions api/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ definitions:
items:
type: string
type: array
queries:
type: integer
type: object
model.AccountUpdate:
properties:
Expand Down
74 changes: 0 additions & 74 deletions api/mocks/account_servicer.go

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

74 changes: 0 additions & 74 deletions api/mocks/servicer.go

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

9 changes: 0 additions & 9 deletions api/model/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ import (
"golang.org/x/crypto/bcrypt"
)

const (
QUERIES_NUMBER_LIMIT = 300000
)

const (
AuthMethodPassword = "password"
AuthMethodPasskey = "passkey"
Expand All @@ -29,7 +25,6 @@ type Account struct {
Tokens []Token `json:"-" bson:"tokens"`
Password *string `json:"-" bson:"password,omitempty"`
Profiles []string `json:"profiles" bson:"profiles"`
Queries int `json:"queries" bson:"-"`
ErrorReportsConsent bool `json:"error_reports_consent" bson:"error_reports_consent"`
MFA MFASettings `json:"mfa" bson:"mfa"`
AuthMethods []string `json:"auth_methods,omitempty" bson:"-"`
Expand Down Expand Up @@ -70,10 +65,6 @@ func NewAccount(email, password, accountId, profileId string) (*Account, error)
return acc, nil
}

func (a *Account) IsQueriesNumberExceeded() bool {
return a.Queries > QUERIES_NUMBER_LIMIT
}

// WebAuthnID implements webauthn.User
func (a *Account) WebAuthnID() []byte {
return []byte(a.ID.Hex())
Expand Down
20 changes: 0 additions & 20 deletions api/service/account/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,11 +317,6 @@ func (p *AccountService) GetAccount(ctx context.Context, accountId string) (*mod
return nil, err
}

stats, err := p.GetAccountMetrics(ctx, account, model.LAST_MONTH)
if err != nil {
return nil, err
}
account.Queries = stats.Total
if err := p.populateAuthMethods(ctx, account); err != nil {
return nil, err
}
Expand All @@ -348,21 +343,6 @@ func (a *AccountService) populateAuthMethods(ctx context.Context, acc *model.Acc
return nil
}

// GetAccountStatistics returns profile DNS statistics data
func (a *AccountService) GetAccountMetrics(ctx context.Context, account *model.Account, timespan string) (*model.StatisticsAggregated, error) {
accMetricsAggregated := &model.StatisticsAggregated{}
for _, profileId := range account.Profiles {
profileStats, err := a.ProfileService.GetStatistics(ctx, account.ID.Hex(), profileId, timespan)
if err != nil {
return nil, err
}

accMetricsAggregated.Total += profileStats[0].Total
}

return accMetricsAggregated, nil
}

// UpdateAccount updates account data
func (a *AccountService) UpdateAccount(ctx context.Context, accountId string, updates []model.AccountUpdate, mfa *model.MfaData) error {
var profileUpdates []model.AccountUpdate
Expand Down
Loading
Loading