Skip to content

armgit / floci

Public Imported from GitHub
0

Light, fluffy, and always free - The AWS Local Emulator alternative

fix(cloudmap): avoid SecureRandom in native image heap (#1289)

Hector Ventura898615707d12
diff --git a/src/main/java/io/github/hectorvent/floci/services/cloudmap/CloudMapService.java b/src/main/java/io/github/hectorvent/floci/services/cloudmap/CloudMapService.java
index d6957bb420..60f8de28b1 100644
--- a/src/main/java/io/github/hectorvent/floci/services/cloudmap/CloudMapService.java
+++ b/src/main/java/io/github/hectorvent/floci/services/cloudmap/CloudMapService.java
@@ -38,7 +38,8 @@ public class CloudMapService {
private static final Logger LOG = Logger.getLogger(CloudMapService.class);
private static final String ALNUM = "abcdefghijklmnopqrstuvwxyz0123456789";
- private static final SecureRandom RANDOM = new SecureRandom();
+
+ private final SecureRandom random = new SecureRandom();
private final StorageBackend<String, Namespace> namespaceStore;
private final StorageBackend<String, Service> serviceStore;
@@ -540,7 +541,7 @@ public class CloudMapService {
private String randomId(int length) {
StringBuilder sb = new StringBuilder(length);
for (int i = 0; i < length; i++) {
- sb.append(ALNUM.charAt(RANDOM.nextInt(ALNUM.length())));
+ sb.append(ALNUM.charAt(random.nextInt(ALNUM.length())));
}
return sb.toString();
}
@@ -549,7 +550,7 @@ public class CloudMapService {
StringBuilder sb = new StringBuilder("Z");
String chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
for (int i = 0; i < 13; i++) {
- sb.append(chars.charAt(RANDOM.nextInt(chars.length())));
+ sb.append(chars.charAt(random.nextInt(chars.length())));
}
return sb.toString();
}
diff --git a/src/main/resources/application.yml.bak b/src/main/resources/application.yml.bak
deleted file mode 100644
index 1480f12968..0000000000
--- a/src/main/resources/application.yml.bak
+++ /dev/null
@@ -1,189 +0,0 @@
-quarkus:
- http:
- port: ${floci.port}
- host: 0.0.0.0
- limits:
- max-body-size: ${floci.max-request-size}M
- shutdown:
- # Enables the pre-shutdown phase so stop hooks run before the HTTP server stops.
- # No 'delay' value is set - observers run synchronously, no artificial sleep is introduced.
- delay-enabled: true
- native:
- additional-build-args: >-
- --initialize-at-run-time=org.apache.hc.client5.http.impl.auth.NTLMEngineImpl,
- --initialize-at-run-time=com.github.dockerjava.transport.NamedPipeSocket$Kernel32,
- --initialize-at-run-time=org.bouncycastle.jcajce.provider.drbg.DRBG$Default,
- --initialize-at-run-time=org.bouncycastle.jcajce.provider.drbg.DRBG$NonceAndIV,
- --initialize-at-run-time=org.bouncycastle.crypto.prng.SP800SecureRandom,
- --initialize-at-run-time=org.bouncycastle.jce.provider.BouncyCastleProvider,
- --initialize-at-run-time=io.github.hectorvent.floci.core.common.BouncyCastleInitializer,
- --initialize-at-run-time=io.github.hectorvent.floci.services.acm.AcmService,
- --initialize-at-run-time=io.github.hectorvent.floci.services.acm.CertificateGenerator,
- --initialize-at-run-time=io.github.hectorvent.floci.services.cognito.CognitoSrpHelper
-
-floci:
- port: 4566
- max-request-size: 512
- base-url: "http://localhost:4566"
- # hostname: "" # When set, overrides the hostname in response URLs (e.g. SQS QueueUrl).
- # Needed for multi-container Docker setups. Example: FLOCI_HOSTNAME=floci
- default-region: us-east-1
- default-account-id: "000000000000"
- storage:
- # Supported modes: memory, persistent, hybrid, wal
- mode: memory
- persistent-path: ./data
- host-persistent-path: ./data
- wal:
- compaction-interval-ms: 30000
- services:
- ssm:
- flush-interval-ms: 5000
- dynamodb:
- flush-interval-ms: 5000
- sns:
- flush-interval-ms: 5000
- lambda:
- flush-interval-ms: 5000
- cloudwatchlogs:
- flush-interval-ms: 5000
- cloudwatchmetrics:
- flush-interval-ms: 5000
- secretsmanager:
- flush-interval-ms: 5000
- acm:
- flush-interval-ms: 5000
- opensearch:
- flush-interval-ms: 5000
-
- auth:
- validate-signatures: false
- presign-secret: local-emulator-secret
-
- docker:
- log-max-size: "10m"
- log-max-file: "3"
- docker-host: unix:///var/run/docker.sock
- docker-config-path: ""
- registry-credentials: []
-
- services:
- ssm:
- enabled: true
- max-parameter-history: 5
- sqs:
- enabled: true
- default-visibility-timeout: 30
- max-message-size: 262144
- s3:
- enabled: true
- default-presign-expiry-seconds: 3600
- dynamodb:
- enabled: true
- sns:
- enabled: true
- lambda:
- enabled: true
- ephemeral: false
- default-memory-mb: 128
- default-timeout-seconds: 3
- runtime-api-base-port: 9200
- runtime-api-max-port: 9299
- code-path: ./data/lambda-code
- poll-interval-ms: 1000
- container-idle-timeout-seconds: 300
- region-concurrency-limit: 1000
- unreserved-concurrency-min: 100
- apigateway:
- enabled: true
- apigatewayv2:
- enabled: true
- iam:
- enabled: true
- enforcement-enabled: false
- msk:
- enabled: true
- mock: false
- default-image: "redpandadata/redpanda:latest"
- elasticache:
- enabled: true
- proxy-base-port: 6379
- proxy-max-port: 6399
- default-image: "valkey/valkey:8"
- rds:
- enabled: true
- proxy-base-port: 7001
- proxy-max-port: 7099
- default-postgres-image: "postgres:16-alpine"
- default-mysql-image: "mysql:8.0"
- default-mariadb-image: "mariadb:11"
- eventbridge:
- enabled: true
- scheduler:
- enabled: true
- cloudwatchlogs:
- enabled: true
- max-events-per-query: 10000
- cloudwatchmetrics:
- enabled: true
- secretsmanager:
- enabled: true
- default-recovery-window-days: 30
- kinesis:
- enabled: true
- firehose:
- enabled: true
- kms:
- enabled: true
- cognito:
- enabled: true
- stepfunctions:
- enabled: true
- cloudformation:
- enabled: true
- acm:
- enabled: true
- validation-wait-seconds: 0
- athena:
- enabled: true
- glue:
- enabled: true
- ses:
- enabled: true
- opensearch:
- enabled: true
- mock: false
- default-image: "opensearchproject/opensearch:2"
- proxy-base-port: 9400
- proxy-max-port: 9499
- keep-running-on-shutdown: false
- ec2:
- enabled: true
- ecs:
- enabled: true
- mock: false
- appconfig:
- enabled: true
- appconfigdata:
- enabled: true
- ecr:
- enabled: true
- registry-image: "registry:2"
- registry-container-name: floci-ecr-registry
- registry-base-port: 5100
- registry-max-port: 5199
- data-path: ./data/ecr
- tls-enabled: false
- keep-running-on-shutdown: true
- uri-style: hostname
- bedrock-runtime:
- enabled: true
- eks:
- enabled: true
- mock: false
- provider: k3s
- default-image: "rancher/k3s:latest"
- api-server-base-port: 6500
- api-server-max-port: 6599
- data-path: ./data/eks
- keep-running-on-shutdown: false