-
Notifications
You must be signed in to change notification settings - Fork 0
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
26 use mariadb + split repository layer #27
Changes from all commits
9edf652
c64ba66
ee51f53
d09bb0f
d6651fc
1d1d712
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,69 +26,33 @@ services: | |
|
||
|
||
|
||
cassandra-extractor: | ||
image: busybox:latest | ||
container_name: cassandra-extractor | ||
volumes: | ||
- ./docker/cassandra_exporter/datastax-mcac-agent-0.3.5.tar.gz:/opt/datastax-mcac-agent-0.3.5.tar.gz | ||
- cassandra_mcac:/opt/datastax-mcac-agent-0.3.5 | ||
command: sh -c "tar -xzf /opt/datastax-mcac-agent-0.3.5.tar.gz -C /opt/" | ||
|
||
|
||
d1r1n1: | ||
image: cassandra:4.0.12 | ||
container_name: d1r1n1 | ||
environment: &environment | ||
CASSANDRA_SEEDS: d1r1n1 | ||
CASSANDRA_CLUSTER_NAME: C1 | ||
CASSANDRA_DC: D1 | ||
CASSANDRA_RACK: R1 | ||
CASSANDRA_ENDPOINT_SNITCH: GossipingPropertyFileSnitch | ||
CASSANDRA_NUM_TOKENS: 128 | ||
JVM_OPTS: -javaagent:/opt/datastax-mcac-agent-0.3.5/lib/datastax-mcac-agent.jar | ||
mariadb: | ||
image: 'mariadb:11.3.2' | ||
container_name: mariadb | ||
environment: | ||
- 'MARIADB_DATABASE=hicha' | ||
- 'MARIADB_PASSWORD=secret' | ||
- 'MARIADB_ROOT_PASSWORD=verysecret' | ||
- 'MARIADB_USER=myuser' | ||
ports: | ||
- "9042:9042" | ||
- "9103:9103" | ||
depends_on: | ||
cassandra-extractor: | ||
condition: service_completed_successfully | ||
volumes: &mcac | ||
- cassandra_mcac:/opt/datastax-mcac-agent-0.3.5 | ||
healthcheck: | ||
test: [ "CMD-SHELL", "[ $$(nodetool statusgossip) = running ]" ] | ||
|
||
- '3306:3306' | ||
|
||
# deploy: | ||
# resources: | ||
# limits: | ||
# cpus: '1' # Minimum CPU requirement for MariaDB (10% of one core) | ||
# memory: 256M # Minimum memory requirement for MariaDB (256MB) | ||
|
||
d1r1n2: | ||
image: cassandra:4.0.12 | ||
container_name: d1r1n2 | ||
ports: | ||
- "9043:9042" | ||
- "9104:9103" | ||
environment: | ||
<<: *environment | ||
|
||
volumes: *mcac | ||
depends_on: | ||
d1r1n1: | ||
condition: service_healthy | ||
cassandra-extractor: | ||
condition: service_completed_successfully | ||
|
||
d1r1n3: | ||
image: cassandra:4.0.12 | ||
container_name: d1r1n3 | ||
mariadb-exporter: | ||
container_name: mariadb-exporter | ||
image: 'prom/mysqld-exporter' | ||
restart: always | ||
command: | ||
- "--mysqld.username=root:verysecret" | ||
- "--mysqld.address=host.docker.internal:3306" | ||
ports: | ||
- "9044:9042" | ||
- "9105:9103" | ||
environment: | ||
<<: *environment | ||
volumes: *mcac | ||
depends_on: | ||
d1r1n1: | ||
condition: service_healthy | ||
cassandra-extractor: | ||
condition: service_completed_successfully | ||
- "9104:9104" | ||
Comment on lines
+47
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tip Codebase Verification The configuration of the
It is recommended to use more secure methods for handling credentials, such as environment variables or configuration files that are not exposed. Analysis chainVerify the configuration of the mariadb-exporter for security. Scripts ExecutedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Check the security settings of the mariadb-exporter service.
# Test: Search for security best practices in the configuration of mariadb-exporter. Expect: Secure practices like non-root user, minimal permissions.
rg --type yaml $'mariadb-exporter' | rg 'user|permissions'
Length of output: 57 Script: #!/bin/bash
# Description: Check for secure handling of credentials and network settings in mariadb-exporter configuration.
# Test: Search for any instance of credentials being passed in command lines and check for network exposure settings.
rg --type yaml --context 5 $'mariadb-exporter' | rg 'command|ports'
Length of output: 92 Script: #!/bin/bash
# Description: Extract the full command line arguments for mariadb-exporter to assess how credentials are handled.
# Test: Search for the complete command line arguments in the mariadb-exporter configuration.
rg --type yaml --context 10 $'mariadb-exporter' | rg 'command'
Length of output: 85 |
||
|
||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
insert into users(username) value ('huyvu'), ('admin'), ('testuser'); | ||
insert into conversations () value (); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The SQL statement for inserting conversations is empty and does not specify values. Please clarify if this is intentional or an oversight. |
||
INSERT INTO user_conversations (user_id, conversation_id) VALUES ((select users.user_id from users where username = 'huyvu' limit 1), (select conversation_id from conversations limit 1)); | ||
insert into messages (conversation_id, sender_id, message_text) | ||
values (1, 1, 'This is a test message.'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package io.huyvu.hicha; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class HichaBusinessApplication { | ||
public static void main(String[] args) { | ||
SpringApplication.run(HichaBusinessApplication.class, args); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package io.huyvu.hicha.controller; | ||
|
||
import io.huyvu.hicha.model.ConversationDetails; | ||
import io.huyvu.hicha.repository.model.Message; | ||
import io.huyvu.hicha.repository.repo.MessageRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.time.Instant; | ||
|
||
@RestController | ||
@RequestMapping("api/v1/message") | ||
@RequiredArgsConstructor | ||
public class MessageController { | ||
private final MessageRepository messageRepository; | ||
|
||
@PostMapping | ||
void sendMessage(@RequestBody Message message) { | ||
if(message.getSentAt() == null){ | ||
message.setSentAt(Instant.now()); | ||
} | ||
messageRepository.save(message); | ||
} | ||
|
||
@GetMapping("{id}") | ||
ConversationDetails getConversationDetails(@PathVariable Long id) { | ||
var messages = messageRepository.findByConversationId(id); | ||
return ConversationDetails.builder() | ||
.conversationId(id) | ||
.conversationName("Conversation " + id) | ||
.messages(messages) | ||
.build(); | ||
} | ||
} |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
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.
Ensure secure default settings for MariaDB.
The environment variables for MariaDB, such as
MARIADB_PASSWORD
andMARIADB_ROOT_PASSWORD
, are set to simple values which might not be secure. Consider using more complex passwords and managing them through secure means like Docker secrets or environment variables.