-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SQL refactor #287
base: master
Are you sure you want to change the base?
SQL refactor #287
Conversation
…of items upon update, create DB helpers, add godotenv
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, great work
I left one question at spec discussion.
Tried locally - works fine, I saw TRANSIENT_ERROR/SQL rollout not ready
- but then client status turned to SUCCESS
.
@@ -70,3 +75,14 @@ services: | |||
- ALLOW_EMPTY_PASSWORD=yes | |||
networks: | |||
- sync | |||
postgres: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reported by reviewdog 🐶
[semgrep] Service 'postgres' allows for privilege escalation via setuid or setgid binaries. Add 'no-new-privileges=true' in 'security_opt' to prevent this.
Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/docker-compose-no-new-privileges.yaml
Cc @thypon kdenhartog
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The combination of this one with the additional one below do look like they'll present issues. Should be an easy fix to add the no-new-privileges=true
configuration to this file. If there's a reason we intentionally haven't done this though @DJAndries let me know and we can determine together what the best way forward is.
@@ -70,3 +75,14 @@ services: | |||
- ALLOW_EMPTY_PASSWORD=yes | |||
networks: | |||
- sync | |||
postgres: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reported by reviewdog 🐶
[semgrep] Service 'postgres' is running with a writable root filesystem. This may allow malicious applications to download and run additional payloads, or modify container files. If an application inside a container has to save something temporarily consider using a tmpfs. Add 'read_only: true' to this service to prevent this.
Source: https://semgrep.dev/r/yaml.docker-compose.security.writable-filesystem-service.writable-filesystem-service
Cc @thypon kdenhartog
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, seems like a simple solution to solve this is to add the read_only: true
configuration. If you can't let me know and we'll figure out the best way forward @DJAndries.
if !h.SQLDB.Variations().Ready { | ||
return nil, nil | ||
} | ||
if rand.Float32() > h.SQLDB.MigrateIntervalPercent() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
non blocking question: @DJAndries what's the purpose in this validation check? The logic is non-deterministic in the sense that rand could return a very large number forcing this to fail the migration. Is this intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to reduce DB load, we only want to migrate chunks of data from ddb to pg on a certain percentage of "get update" requests from the client, which are sent every 30 seconds. the check enforces this requirement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will add a comment for clarity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want a more uniform randomness, crypto/rand can provide that guarantee, but based on that answer it doesn't seem like we really need that so feel free to ignore that sec-actions comment.
|
||
import ( | ||
"fmt" | ||
"math/rand/v2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reported by reviewdog 🐶
[semgrep] Do not use math/rand
. Use crypto/rand
instead.
Source: https://semgrep.dev/r/go.lang.security.audit.crypto.math_random.math-random-used
Cc @thypon @kdenhartog
@@ -0,0 +1,9 @@ | |||
FROM public.ecr.aws/docker/library/postgres:16 | |||
|
|||
RUN apt update && apt install -y git make gcc postgresql-server-dev-16 |
Check notice
Code scanning / SonarCloud
Arguments in long RUN instructions should be sorted Low
[puLL-Merge] - brave/go-sync@287 DescriptionThis PR introduces significant changes to the codebase, primarily focusing on adding support for SQL databases alongside the existing DynamoDB implementation. It also includes improvements to the data migration process, updates to the project structure, and enhancements to the testing suite. ChangesChanges
Possible Issues
Security Hotspots
|
Resolves #216