Skip to content

Commit

Permalink
Merge branch 'develop' into test/MIDAZ-340
Browse files Browse the repository at this point in the history
  • Loading branch information
maxwelbm authored Dec 10, 2024
2 parents cbe9765 + 3506810 commit b078adf
Show file tree
Hide file tree
Showing 120 changed files with 9,688 additions and 1,226 deletions.
1 change: 1 addition & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- [ ] Ledger
- [ ] Mdz
- [ ] Transaction
- [ ] Audit
- [ ] Pipeline
- [ ] Documentation

Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/midaz-update-repos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ jobs:
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
cp midaz/components/ledger/api/swagger.json LerianStudio.github.io/ledger/
cp midaz/components/audit/api/swagger.json LerianStudio.github.io/audit/
cp midaz/components/ledger/api/swagger.json LerianStudio.github.io/ledger/
cp midaz/components/transaction/api/swagger.json LerianStudio.github.io/transaction/
- name: Commit and Push Swagger to Git Page
Expand All @@ -132,6 +134,9 @@ jobs:
git remote set-url origin https://${{ secrets.MANAGE_TOKEN }}@github.com/LerianStudio/LerianStudio.github.io.git
git add audit
git commit -S -m "Update Swagger.json from Repo Audit"
git add ledger
git commit -S -m "Update Swagger.json from Repo Ledger"
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/update-env-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ jobs:
echo "LEDGER version: $VERSION"
echo "::set-output name=version::$VERSION"
- name: Update AUDIT Env
if: steps.latest_release.outputs.tag != steps.env_release.outputs.version
run: |
sed -i "s/^VERSION=.*/VERSION=${{ steps.latest_release.outputs.tag }}/" ./components/audit/.env.example
- name: Update LEDGER Env
if: steps.latest_release.outputs.tag != steps.env_release.outputs.version
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ components/mdz/bin/mdz
.idea
*.iml
components/ledger/_docker-compose.yml
coverage.out
86 changes: 86 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,89 @@
## [1.31.0-beta.14](https://github.com/LerianStudio/midaz/compare/v1.31.0-beta.13...v1.31.0-beta.14) (2024-12-06)


### Features

* **audit:** add audit logs handler :sparkles: ([4a5fe36](https://github.com/LerianStudio/midaz/commit/4a5fe36a69fb9342d962c07a5fafdb64bbdfcfa4))
* **audit:** add authorization for routes :sparkles: ([2700d50](https://github.com/LerianStudio/midaz/commit/2700d50d93fbdb2203dc8ef19335d26f86737e45))
* **audit:** add custom error messages :sparkles: ([db9bc72](https://github.com/LerianStudio/midaz/commit/db9bc72195faa6bbb6d143260baa34e0db7d032c))
* **audit:** add get audit info use case :sparkles: ([9cc6503](https://github.com/LerianStudio/midaz/commit/9cc65035dd99edb6a1626acc67efec0d1fad108d))
* **audit:** add get log by hash use case :sparkles: ([66d3b93](https://github.com/LerianStudio/midaz/commit/66d3b9379ac47475f9f32f9fe70e1c52ce9d46b7))
* **audit:** add methods for retrieving trillian inclusion proof and leaf by index :sparkles: ([03b12bd](https://github.com/LerianStudio/midaz/commit/03b12bdd406cab91295d0bd21de96574f8c09e53))
* **audit:** add trace spans :sparkles: ([1ea30fa](https://github.com/LerianStudio/midaz/commit/1ea30fab9d2c75bebd51309d709a9b833d0b66d4))
* **audit:** add trillian health check before connecting :sparkles: ([9295cec](https://github.com/LerianStudio/midaz/commit/9295cec1036dd77da7d843c38603247be2d46ed5))
* add update swagger audit on git pages ([137824a](https://github.com/LerianStudio/midaz/commit/137824a9f721e140a4ecb7ec08cca07c99762b59))
* **audit:** add validate log use case :sparkles: ([7216c5e](https://github.com/LerianStudio/midaz/commit/7216c5e744d0246961db040f6c045c60452b1dc1))
* audit component :sparkles: ([084603f](https://github.com/LerianStudio/midaz/commit/084603f08386b7ebcfa67eaac7b094ddf676976f))
* **audit:** audit structs to aux mongo database ([4b80b75](https://github.com/LerianStudio/midaz/commit/4b80b75a16cefb77a4908e04b7ac522e347fb8eb))
* create audit app ([f3f8cd5](https://github.com/LerianStudio/midaz/commit/f3f8cd5f3e7e8023e17e1f17111e9e221ec62227))
* **auth:** create auditor user :sparkles: ([5953ad9](https://github.com/LerianStudio/midaz/commit/5953ad9ac44faa3c8c9014eb47d480176f6d49ca))
* create route consumer for many queues ([8004063](https://github.com/LerianStudio/midaz/commit/8004063186d6c85bd0ed99e5d081acdc9ecdfb8f))
* **audit:** create struct for queue messages :sparkles: ([646bd38](https://github.com/LerianStudio/midaz/commit/646bd38cced4fc57f51fb2e5bd3d3137ba2a83bc))
* **audit:** create structs for audit transaction message ([fa6b568](https://github.com/LerianStudio/midaz/commit/fa6b568d83b165d59540ee7878e550f81ddc3789))
* **audit:** create transaction logs from rabbitmq message ([d54e4d3](https://github.com/LerianStudio/midaz/commit/d54e4d387e08ea5d9a47898bd0e94df7ab5c2f5d))
* **audit:** create trillian log leaf ([d18c0c2](https://github.com/LerianStudio/midaz/commit/d18c0c22f540196e575bfc1f0656da1fb5747a54))
* **audit:** errors return from log creation :sparkles: ([69594e4](https://github.com/LerianStudio/midaz/commit/69594e4e24eb6d107b2d8fa27f83d0e76e058405))
* **audit:** find audit info by ID :sparkles: ([ea91e97](https://github.com/LerianStudio/midaz/commit/ea91e971ac2db8cd8a7befe2e42d994e6987902f))
* **audit:** ignore updatable fields for operation :sparkles: ([28db38d](https://github.com/LerianStudio/midaz/commit/28db38d0e391904458fd8234303f6f56b412e6c3))
* **audit:** implement get trillian log by hash :sparkles: ([44d103b](https://github.com/LerianStudio/midaz/commit/44d103bbef1e80acd37ecd5c5e3d4ce238ea8530))
* **audit:** implement rabbitmq consumer :sparkles: ([9874dc4](https://github.com/LerianStudio/midaz/commit/9874dc453cfcbb94379c9e256c6aeeacef136bc9))
* implement trillian connection :sparkles: ([c4b8877](https://github.com/LerianStudio/midaz/commit/c4b887706dd4ce4ea8c7f7358ff40854f60bc2a6))
* **audit:** implements read logs by transaction handler :sparkles: ([d134b07](https://github.com/LerianStudio/midaz/commit/d134b07e7715f05b9e32817a47fe95ded1721c7b))
* **audit:** receiving audit parameter to create tree ([be43f32](https://github.com/LerianStudio/midaz/commit/be43f324ac21354c60a65ce2beda5f1c4f78871f))
* **audit:** returning log leaf instead of the value :sparkles: ([9b40d88](https://github.com/LerianStudio/midaz/commit/9b40d88189c3021e637cc3ce52686895b5b83130))
* right way of starter audit with only one queue consumer ([15a0a8c](https://github.com/LerianStudio/midaz/commit/15a0a8c9438d31597d749d3180adcd4a9eb994bc))
* **audit:** starting implementation of server :sparkles: ([edbce7b](https://github.com/LerianStudio/midaz/commit/edbce7bc2281c7d1273215dc372573e58680119c))
* **audit:** update audit info collection name :sparkles: ([7cd39fa](https://github.com/LerianStudio/midaz/commit/7cd39fa0861b06c7a728f9c25e44f656d2be7b50))
* **audit:** update audit route paths :sparkles: ([0f12899](https://github.com/LerianStudio/midaz/commit/0f128998b6525c4419e3e4acd388aac97e92cb48))
* **audit:** using generic queue struct instead of transaction to write logs :sparkles: ([4c1b86f](https://github.com/LerianStudio/midaz/commit/4c1b86f0f374d182ee39b430ea19b641bad4eca0))
* **audit:** work with generic audit log values :sparkles: ([9beb218](https://github.com/LerianStudio/midaz/commit/9beb21876f2cc57aacaabee502c45712e68102db))


### Bug Fixes

* **audit:** add audit_id parameter to uuid path parameters constant :bug: ([dcbcb05](https://github.com/LerianStudio/midaz/commit/dcbcb05de4d2f1cfb9340a807f299af6bb302c5f))
* **audit:** add tree size validation to fix vulnerability :bug: ([313dbf4](https://github.com/LerianStudio/midaz/commit/313dbf40f06d088e2d36282f57a7585db3e5ab7a))
* adjust to change run :bug: ([bad23fe](https://github.com/LerianStudio/midaz/commit/bad23fedda288507b87ae68dcfbe35b6a66285cf))
* adjust to run rabbit and fiber at same time :bug: ([4ec503f](https://github.com/LerianStudio/midaz/commit/4ec503fa0fa2a457b2c055d7585d80edba46cd48))
* adjust to test rabbit receiving data :bug: ([38d3ec9](https://github.com/LerianStudio/midaz/commit/38d3ec9908429171c9de4a772cb082dbdfdb17a8))
* **audit:** change log level for mtrillian :bug: ([06bd3f8](https://github.com/LerianStudio/midaz/commit/06bd3f8d55a84f3509bdcd5fa60ac7726d83cf5c))
* **audit:** change otel exporter service name :bug: ([85c15b4](https://github.com/LerianStudio/midaz/commit/85c15b45010d43c9bdd702b9d55e42186eb2b6d2))
* change rabbit and mongo envs for audit component :bug: ([2854909](https://github.com/LerianStudio/midaz/commit/2854909dcb3a2f902fec9bdec923ad3d41d4ac9e))
* **audit:** fix field name :bug: ([eb8f647](https://github.com/LerianStudio/midaz/commit/eb8f647c45bcdf00776b4f57487d0ba7d0575cc2))
* **audit:** handle audit not found error only :bug: ([212ebac](https://github.com/LerianStudio/midaz/commit/212ebaca6c85dd12b150e273754648a805359710))
* **audit:** make constants public :bug: ([baaee67](https://github.com/LerianStudio/midaz/commit/baaee675eaae47695a7dd00df93677bb5e60b0ff))
* merge git :bug: ([65a985a](https://github.com/LerianStudio/midaz/commit/65a985ac9c3758aaeca4fd861bb141fc095472f3))
* **audit:** nack message when an error occurs :bug: ([88090b0](https://github.com/LerianStudio/midaz/commit/88090b09b9377172ad77f4378139fae7441e0d04))
* **audit:** otel envs :bug: ([6328d90](https://github.com/LerianStudio/midaz/commit/6328d905a1f5f7e9dba5201ccd16fce3d884909a))
* rabbit init on server before fiber :bug: ([51c1b53](https://github.com/LerianStudio/midaz/commit/51c1b53eada3fd2cfbcc18557c101554607c74a1))
* **ledger:** remove create audit tree from ledger creation :bug: ([8783145](https://github.com/LerianStudio/midaz/commit/878314570180bd8f1855572d435b37210e711218))
* remove second queue consumer after tests :bug: ([8df4703](https://github.com/LerianStudio/midaz/commit/8df470377954add22e5ebb2422c69ee68931746c))
* **audit:** shutdown when consumer error :bug: ([22b24c9](https://github.com/LerianStudio/midaz/commit/22b24c90c67492d58ba4aa043f3a9d3513280777))
* **audit:** trillian server host name :bug: ([84b73ff](https://github.com/LerianStudio/midaz/commit/84b73ffdbae04d3c207155b976bab60d59e285ab))
* update audit env version :bug: ([79475b2](https://github.com/LerianStudio/midaz/commit/79475b268aaac99b30f381a60cff4d41b5bfeffb))
* **audit:** update components/audit/internal/adapters/http/in/response.go ([3d8d8cd](https://github.com/LerianStudio/midaz/commit/3d8d8cd6ca41444132ef6682dede5e6f54859bc5))

## [1.31.0-beta.13](https://github.com/LerianStudio/midaz/compare/v1.31.0-beta.12...v1.31.0-beta.13) (2024-12-06)


### Bug Fixes

* adjust to return nil and not empty struct :bug: ([a2a73b8](https://github.com/LerianStudio/midaz/commit/a2a73b851e2af5f43bfc445efdb565c281aef94c))
* go lint :bug: ([0123db1](https://github.com/LerianStudio/midaz/commit/0123db151fa218b044c189613f0b80cbc66aa105))
* remove G :bug: ([9fe64e1](https://github.com/LerianStudio/midaz/commit/9fe64e1a38aba6e851570e44b3aac8e1b61be795))
* update makefile to reference common to pkg :bug: ([c6963ea](https://github.com/LerianStudio/midaz/commit/c6963eae0776b3da149345e52f40649669adf02a))

## [1.31.0-beta.12](https://github.com/LerianStudio/midaz/compare/v1.31.0-beta.11...v1.31.0-beta.12) (2024-12-06)

## [1.31.0-beta.11](https://github.com/LerianStudio/midaz/compare/v1.31.0-beta.10...v1.31.0-beta.11) (2024-12-06)


### Bug Fixes

* **account:** omit optional fields in update request payload :bug: ([33f3e7d](https://github.com/LerianStudio/midaz/commit/33f3e7dac14088b8a6ff293ed4625eeef62a9448))

## [1.31.0-beta.10](https://github.com/LerianStudio/midaz/compare/v1.31.0-beta.9...v1.31.0-beta.10) (2024-12-06)

## [1.31.0-beta.9](https://github.com/LerianStudio/midaz/compare/v1.31.0-beta.8...v1.31.0-beta.9) (2024-12-04)


Expand Down
18 changes: 14 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ INFRA_DIR := ./components/infra
LEDGER_DIR := ./components/ledger
TRANSACTION_DIR := ./components/transaction
MDZ_DIR := ./components/mdz
AUDIT_DIR := ./components/audit

.PHONY: help test cover lint format check-logs check-tests \
setup-git-hooks check-hooks goreleaser tidy sec set-env up auth infra ledger \
transaction all-services
transaction audit all-services

BLUE := \033[36m
NC := \033[0m
Expand Down Expand Up @@ -46,6 +47,7 @@ help:
@echo " make infra Run a command inside the infra app in the components directory to see available commands."
@echo " make ledger Run a command inside the ledger app in the components directory to see available commands."
@echo " make transaction Run a command inside the transaction app in the components directory to see available commands."
@echo " make audit Run a command inside the audit app in the components directory to see available commands."
@echo " make set-env Run a command to copy all .env.example to .env into respective folders."
@echo " make all-services Run a command to all services passing any individual container command."
@echo " make generate-docs-all Run a command to inside the ledger and transaction app to generate swagger docs."
Expand All @@ -56,6 +58,7 @@ help:
@echo " make infra COMMAND=<cmd> - Run command in infra service"
@echo " make ledger COMMAND=<cmd> - Run command in ledger service"
@echo " make transaction COMMAND=<cmd> - Run command in transaction service"
@echo " make audit COMMAND=<cmd> - Run command in audit service"
@echo " make all-services COMMAND=<cmd> - Run command across all services"
@echo ""
@echo "$(BOLD)Development Commands:$(NC)"
Expand All @@ -71,12 +74,13 @@ test:
go test -v ./... ./...

cover:
@echo "$(BLUE)Generating test coverage...$(NC)"
@echo -e "$(BLUE)Generating test coverage...$(NC)"
@if ! command -v go >/dev/null 2>&1; then \
echo "$(RED)Error: go is not installed$(NC)"; \
exit 1; \
fi
go test -cover ./...
@sh ./scripts/coverage.sh
@go tool cover -html=coverage.out -o coverage.html

lint:
@echo "$(BLUE)Running linter and performance checks...$(NC)"
Expand Down Expand Up @@ -118,6 +122,7 @@ set-env:
cp -r $(LEDGER_DIR)/.env.example $(LEDGER_DIR)/.env
cp -r $(TRANSACTION_DIR)/.env.example $(TRANSACTION_DIR)/.env
cp -r $(MDZ_DIR)/.env.example $(MDZ_DIR)/.env
cp -r $(AUDIT_DIR)/.env.example $(AUDIT_DIR)/.env
@echo "$(BLUE)Environment files created successfully$(NC)"

up:
Expand All @@ -144,6 +149,10 @@ transaction:
@echo "$(BLUE)Executing command in transaction service...$(NC)"
$(MAKE) -C $(TRANSACTION_DIR) $(COMMAND)

audit:
@echo "$(BLUE)Executing command in audit service...$(NC)"
$(MAKE) -C $(AUDIT_DIR) $(COMMAND)

all-services:
@echo "$(BLUE)Executing command across all services...$(NC)"
$(MAKE) -C $(AUTH_DIR) $(COMMAND) && \
Expand All @@ -165,4 +174,5 @@ tidy:
generate-docs-all:
@echo "$(BLUE)Executing command to generate swagger...$(NC)"
$(MAKE) -C $(LEDGER_DIR) generate-docs && \
$(MAKE) -C $(TRANSACTION_DIR) generate-docs
$(MAKE) -C $(TRANSACTION_DIR) generate-docs && \
$(MAKE) -C $(AUDIT_DIR) generate-docs
65 changes: 65 additions & 0 deletions components/audit/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# DEFAULT local
# ENV_NAME=production

# APP
VERSION=v1.31.0
SERVER_PORT=3005
SERVER_ADDRESS=:${SERVER_PORT}

# LOG LEVEL
LOG_LEVEL=debug

# MONGO DB
MONGO_HOST=midaz-mongodb
MONGO_NAME=audit
MONGO_USER=midaz
MONGO_PASSWORD=lerian
MONGO_PORT=5703

# CASDOOR
CASDOOR_PORT=8080
CASDOOR_ADDRESS=http://midaz-casdoor:${CASDOOR_PORT}
CASDOOR_CLIENT_ID=9670e0ca55a29a466d31
CASDOOR_CLIENT_SECRET=dd03f916cacf4a98c6a413d9c38ba102dce436a9
CASDOOR_ORGANIZATION_NAME=lerian
CASDOOR_APPLICATION_NAME=app-midaz
CASDOOR_MODEL_NAME=api-model
CASDOOR_JWK_ADDRESS=${CASDOOR_ADDRESS}/.well-known/jwks

# OPEN TELEMETRY
OTEL_RESOURCE_SERVICE_NAME=audit
OTEL_LIBRARY_NAME=github.com/LerianStudio/midaz/components/audit
OTEL_RESOURCE_SERVICE_VERSION=${VERSION}
OTEL_RESOURCE_DEPLOYMENT_ENVIRONMENT=${ENV_NAME}
OTEL_EXPORTER_OTLP_ENDPOINT_PORT=4317
OTEL_EXPORTER_OTLP_ENDPOINT=midaz-otel-lgtm:${OTEL_EXPORTER_OTLP_ENDPOINT_PORT}

# RABBITMQ
RABBITMQ_HOST=midaz-rabbitmq
RABBITMQ_PORT_HOST=3003
RABBITMQ_PORT_AMPQ=3004
RABBITMQ_DEFAULT_USER=audit
RABBITMQ_DEFAULT_PASS=lerian
RABBITMQ_QUEUE=audit_queue

# TRILLIAN
TRILLIAN_DATABASE_NAME=audit-db
TRILLIAN_DATABASE_USER=midaz
TRILLIAN_DATABASE_PASSWORD=lerian
TRILLIAN_DATABASE_ROOT_PASSWORD=lerian
TRILLIAN_DATABASE_PORT=5705
TRILLIAN_GRPC_PORT=8082
TRILLIAN_HTTP_PORT=8083
TRILLIAN_SIGNER_PORT=8084
TRILLIAN_GRPC_ADDRESS=midaz-audit-server:${TRILLIAN_GRPC_PORT}
TRILLIAN_HTTP_ADDRESS=http://midaz-audit-server:${TRILLIAN_HTTP_PORT}

# SWAGGER
SWAGGER_TITLE=Audit API
SWAGGER_DESCRIPTION=Documentation for the Midaz Audit API
SWAGGER_VERSION=${VERSION}
SWAGGER_HOST=${SERVER_ADDRESS}
SWAGGER_BASE_PATH=/
SWAGGER_SCHEMES=http
SWAGGER_LEFT_DELIMITER={{
SWAGGER_RIGHT_DELIMITER=}}
15 changes: 15 additions & 0 deletions components/audit/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM golang:1.23-alpine AS builder

WORKDIR /audit-app

COPY . .

RUN CGO_ENABLE=0 GOOS=linux go build -a -tags netgo -ldflags '-w -extldflags "-static"' -o /app components/audit/cmd/app/main.go

FROM alpine:latest

COPY --from=builder /app /app

EXPOSE 3005

ENTRYPOINT ["/app"]
Loading

0 comments on commit b078adf

Please sign in to comment.