mirror of
https://github.com/whyour/qinglong.git
synced 2026-09-20 16:07:11 +08:00
fix(ql3): project cnpg runtime trust into private files
This commit is contained in:
@@ -51,12 +51,21 @@ spec:
|
|||||||
value: ql3-postgres-rw.qinglong3-system.svc
|
value: ql3-postgres-rw.qinglong3-system.svc
|
||||||
valueFrom: null
|
valueFrom: null
|
||||||
volumes:
|
volumes:
|
||||||
- name: postgres-runtime-ca
|
- name: postgres-runtime-projected
|
||||||
secret:
|
secret: null
|
||||||
secretName: ql3-postgres-ca
|
projected:
|
||||||
|
defaultMode: 292
|
||||||
|
sources:
|
||||||
|
- secret:
|
||||||
|
name: ql3-postgres-ca
|
||||||
items:
|
items:
|
||||||
- key: ca.crt
|
- key: ca.crt
|
||||||
path: ca.crt
|
path: ca.crt
|
||||||
|
- secret:
|
||||||
|
name: ql3-cluster-control-runtime
|
||||||
|
items:
|
||||||
|
- key: api-credential-pepper-keyring.json
|
||||||
|
path: api-credential-pepper-keyring.json
|
||||||
- name: postgres-worker-ingress-ca
|
- name: postgres-worker-ingress-ca
|
||||||
secret:
|
secret:
|
||||||
secretName: ql3-postgres-ca
|
secretName: ql3-postgres-ca
|
||||||
|
|||||||
@@ -439,8 +439,9 @@ function assertRuntimeBinding(readFile, root, findings) {
|
|||||||
);
|
);
|
||||||
const env = envByName(container);
|
const env = envByName(container);
|
||||||
const caVolume = podSpec?.volumes?.find(
|
const caVolume = podSpec?.volumes?.find(
|
||||||
(candidate) => candidate?.name === 'postgres-runtime-ca',
|
(candidate) => candidate?.name === 'postgres-runtime-projected',
|
||||||
);
|
);
|
||||||
|
const projectedSources = caVolume?.projected?.sources;
|
||||||
if (
|
if (
|
||||||
!exactFailClosedApplicationImage(kustomization) ||
|
!exactFailClosedApplicationImage(kustomization) ||
|
||||||
env.get('QL3_POSTGRES_RUNTIME_URL')?.$patch !== 'delete' ||
|
env.get('QL3_POSTGRES_RUNTIME_URL')?.$patch !== 'delete' ||
|
||||||
@@ -458,9 +459,28 @@ function assertRuntimeBinding(readFile, root, findings) {
|
|||||||
'password',
|
'password',
|
||||||
) ||
|
) ||
|
||||||
env.get('QL3_POSTGRES_TLS_SERVERNAME')?.value !== PRIMARY_DNS ||
|
env.get('QL3_POSTGRES_TLS_SERVERNAME')?.value !== PRIMARY_DNS ||
|
||||||
caVolume?.secret?.secretName !== 'ql3-postgres-ca' ||
|
caVolume?.secret !== null ||
|
||||||
JSON.stringify(caVolume?.secret?.items) !==
|
caVolume?.projected?.defaultMode !== 292 ||
|
||||||
JSON.stringify([{ key: 'ca.crt', path: 'ca.crt' }])
|
JSON.stringify(projectedSources) !==
|
||||||
|
JSON.stringify([
|
||||||
|
{
|
||||||
|
secret: {
|
||||||
|
name: 'ql3-postgres-ca',
|
||||||
|
items: [{ key: 'ca.crt', path: 'ca.crt' }],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
secret: {
|
||||||
|
name: 'ql3-cluster-control-runtime',
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
key: 'api-credential-pepper-keyring.json',
|
||||||
|
path: 'api-credential-pepper-keyring.json',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
])
|
||||||
) {
|
) {
|
||||||
findings.push(
|
findings.push(
|
||||||
finding(
|
finding(
|
||||||
|
|||||||
@@ -126,6 +126,27 @@ test('rejects runtime DSN authority or a non-primary endpoint', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('rejects a runtime projection without both operator CA and keyring', () => {
|
||||||
|
const report = auditCloudNativePgDeployment({
|
||||||
|
root: ROOT,
|
||||||
|
readFile: intercept(
|
||||||
|
'deploy/kubernetes/ql3-cluster/overlays/cloudnative-pg/postgres-runtime-patch.yaml',
|
||||||
|
(source) =>
|
||||||
|
source.replace(
|
||||||
|
' name: ql3-postgres-ca',
|
||||||
|
' name: ql3-cluster-control-runtime',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
});
|
||||||
|
assert.equal(report.compatible, false);
|
||||||
|
assert.equal(
|
||||||
|
report.findings.some(
|
||||||
|
(candidate) => candidate.code === 'QL3_CNPG_RUNTIME_BINDING',
|
||||||
|
),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
test('rejects migration credentials or CA from the runtime domain', () => {
|
test('rejects migration credentials or CA from the runtime domain', () => {
|
||||||
const report = auditCloudNativePgDeployment({
|
const report = auditCloudNativePgDeployment({
|
||||||
root: ROOT,
|
root: ROOT,
|
||||||
|
|||||||
Reference in New Issue
Block a user