devzone 0.48.1 → 0.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env bash
2
+ # Egress proxy helpers for the ephemeral session pod (#220).
3
+ # Sourced by agent-pod-manifest.sh. bash 3.2 compatible ; shellcheck -x clean.
4
+
5
+ agent_pod_egress_mode() {
6
+ kubectl get service -l app.kubernetes.io/component=egress-proxy \
7
+ -o jsonpath='{.items[0].metadata.labels.devzone\.io/egress-mode}' 2>/dev/null || true
8
+ }
9
+
10
+ agent_pod_egress_manifest_lines() {
11
+ local mode="$1"
12
+ [ -n "$mode" ] || return 0
13
+ printf '%s\n' " - name: HTTP_PROXY"
14
+ printf '%s\n' " value: \"http://egress-proxy:3128\""
15
+ printf '%s\n' " - name: HTTPS_PROXY"
16
+ printf '%s\n' " value: \"http://egress-proxy:3128\""
17
+ printf '%s\n' " - name: NO_PROXY"
18
+ printf '%s\n' " value: \"localhost,127.0.0.1,.svc,.cluster.local\""
19
+ }
20
+
21
+ agent_pod_egress_init_lines() {
22
+ local mode="$1" ws_image="$2"
23
+ [ "$mode" = "strict" ] || return 0
24
+ printf '%s\n' " initContainers:"
25
+ printf '%s\n' " - name: wait-egress-restriction"
26
+ printf '%s\n' " image: ${ws_image}"
27
+ printf '%s\n' " command: [\"/bin/bash\", \"-lc\"]"
28
+ printf '%s\n' " args:"
29
+ printf '%s\n' " - 'i=0; while [ \$i -lt 20 ]; do if ! curl --noproxy \"*\" -m 3 -sS https://opencode.ai >/dev/null 2>&1; then exit 0; fi; i=\$((i+1)); sleep 1; done; echo \"egress restriction never became effective: session refused\" >&2; exit 1'"
30
+ printf '%s\n' " securityContext:"
31
+ printf '%s\n' " runAsUser: 1000"
32
+ printf '%s\n' " runAsGroup: 1000"
33
+ printf '%s\n' " allowPrivilegeEscalation: false"
34
+ printf '%s\n' " capabilities:"
35
+ printf '%s\n' " drop: [\"ALL\"]"
36
+ }
@@ -2,6 +2,8 @@
2
2
  # Manifest and validation helpers for the ephemeral session pod (#222).
3
3
  # Sourced by agent-pod.sh.
4
4
  # bash 3.2 compatible ; shellcheck -x clean.
5
+ # shellcheck disable=SC1091
6
+ . "$(dirname "${BASH_SOURCE[0]}")/agent-pod-egress.sh"
5
7
 
6
8
  # --- Defaults ---
7
9
 
@@ -147,7 +149,7 @@ agent_pod_build_manifest() {
147
149
  ticket_block=" devzone.io/agent-ticket: \"${AGENT_POD_TICKET}\""
148
150
  fi
149
151
 
150
- manifest_file="$(mktemp "${TMPDIR:-/tmp}/devzone-agent-pod-manifest.XXXXXX.yaml")"
152
+ manifest_file="$(mktemp "${TMPDIR:-/tmp}/devzone-agent-pod-manifest.XXXXXX.yaml")"; egress_mode="$(agent_pod_egress_mode)"
151
153
 
152
154
  {
153
155
  printf '%s\n' "apiVersion: v1"
@@ -160,6 +162,7 @@ agent_pod_build_manifest() {
160
162
  printf '%s\n' "$ticket_block"
161
163
  fi
162
164
  printf '%s\n' "spec:"
165
+ agent_pod_egress_init_lines "$egress_mode" "$ws_image"
163
166
  printf '%s\n' " restartPolicy: Never"
164
167
  printf '%s\n' " activeDeadlineSeconds: ${DEVZONE_AGENT_POD_ACTIVE_DEADLINE_SECONDS}"
165
168
  printf '%s\n' " automountServiceAccountToken: false"
@@ -191,7 +194,7 @@ agent_pod_build_manifest() {
191
194
  printf '%s\n' " - name: DEVZONE_WORKSPACE"
192
195
  printf '%s\n' " value: \"kubernetes\""
193
196
  printf '%s\n' " - name: DEVZONE_RACINE"
194
- printf '%s\n' " value: \"/workspaces/projets\""
197
+ printf '%s\n' " value: \"/workspaces/projets\""; agent_pod_egress_manifest_lines "$egress_mode"
195
198
  printf '%s\n' " resources:"
196
199
  printf '%s\n' " limits:"
197
200
  printf '%s\n' " cpu: ${DEVZONE_AGENT_POD_CPU_LIMIT}"
@@ -127,8 +127,13 @@ GitOps repository of devzone, written by the devzone commands (never by hand): t
127
127
  gitops_blob() { git hash-object "$1" 2>/dev/null || true; }
128
128
 
129
129
  gitops_sha() {
130
+ local out
130
131
  if gitops_is_gitlab; then gitlab_gitops_sha "$@"; return; fi
131
- gh api "repos/$(gitops_slug)/contents/$1" --jq .sha 2>/dev/null || true
132
+ # A missing file answers 404 with its error body on stdout: never taken
133
+ # for a sha, or a removal would DELETE what is not there (#625)
134
+ out="$(gh api "repos/$(gitops_slug)/contents/$1" --jq .sha 2>/dev/null)" || out=""
135
+ case "$out" in '' | *[!0-9a-f]*) out="" ;; esac
136
+ printf '%s' "$out"
132
137
  }
133
138
 
134
139
  # Writes <file> at <path> of the repository (create or update), <message>
@@ -125,7 +125,8 @@ services_application_delete() {
125
125
 
126
126
  # Every service of the list applied or released: on → namespace, secret and
127
127
  # Application; off → Application removed (namespace and volumes kept); not
128
- # declared: untouched. One failing service does not stop the others
128
+ # declared: untouched. One failing service does not stop the others; a step
129
+ # prints its ✔ only when it succeeded and its ✖ names the service and the step
129
130
  services_reconcile() {
130
131
  local svc state code=0
131
132
  for svc in $SERVICES_LIST; do
@@ -134,18 +135,35 @@ services_reconcile() {
134
135
  on)
135
136
  # Before the namespace and the secret: a misnamed chart applies nothing
136
137
  chart_require "$svc" || { code=2; continue; }
137
- services_namespace_prepare "$svc" || code=1
138
+ services_namespace_prepare "$svc" || {
139
+ echo "✖ $svc: namespace step failed" >&2
140
+ code=1
141
+ continue
142
+ }
138
143
  if command -v "services_secret_$svc" >/dev/null 2>&1; then
139
- "services_secret_$svc" || code=1
144
+ "services_secret_$svc" || {
145
+ echo "✖ $svc: secret step failed" >&2
146
+ code=1
147
+ continue
148
+ }
140
149
  else
141
150
  echo "✖ no secret hook for $svc (services_secret_$svc): the sync will fail" >&2
142
151
  code=1
152
+ continue
143
153
  fi
144
- services_application_apply "$svc" || code=1
154
+ services_application_apply "$svc" || {
155
+ echo "✖ $svc: declare step failed" >&2
156
+ code=1
157
+ continue
158
+ }
145
159
  echo "✔ Application $(services_app_of "$svc") declared (chart charts/devzone-$svc)"
146
160
  ;;
147
161
  off)
148
- services_application_delete "$svc" || code=1
162
+ services_application_delete "$svc" || {
163
+ echo "✖ $svc: remove step failed" >&2
164
+ code=1
165
+ continue
166
+ }
149
167
  echo "✔ Application $(services_app_of "$svc") removed (namespace and volumes kept)"
150
168
  ;;
151
169
  esac
@@ -54,7 +54,7 @@ fi
54
54
  # Claude Code
55
55
  IA_CLAUDE=@anthropic-ai/claude-code@2.1.326
56
56
  # opencode
57
- IA_OPENCODE=opencode-ai@1.19.5
57
+ IA_OPENCODE=opencode-ai@1.19.6
58
58
  IA_PAQUETS=("$IA_CLAUDE" "$IA_OPENCODE")
59
59
  IA_NOMS=("${IA_CLAUDE%@*}" "${IA_OPENCODE%@*}")
60
60
 
package/README.md CHANGED
@@ -444,3 +444,13 @@ Cette commande retire seulement la commande `devzone` de ta machine ; elle ne su
444
444
 
445
445
  devzone est un logiciel libre, distribué sous la [GNU General Public License version 3](https://github.com/SimBienvenueHoulBoumi/devzone/blob/main/LICENSE).
446
446
 
447
+
448
+ ### Mandataire de sortie des sessions d’agent (désactivé par défaut)
449
+
450
+ Limite le réseau sortant des sessions lancées avec `devzone agent --pod` via un mandataire HTTP(S) (Squid) dans le namespace du workspace. Tout est désactivé par défaut : sans activation, le rendu du chart et le manifeste des pods de session restent identiques.
451
+
452
+ - **Modes** : `observation` (le mandataire accepte tout et journalise, aucune coupure, pour construire la liste) ; `strict` (seule la liste de domaines est autorisée, et une NetworkPolicy limite la sortie des pods de session au mandataire et au DNS).
453
+ - **Activer** (Helm) : `egressProxy.enabled=true` et `egressProxy.mode=observation` ou `strict` (liste : `egressProxy.allowedDomains`, par défaut `.opencode.ai`, `.npmjs.org`, `.github.com`).
454
+ - **Lire les contacts** : `kubectl logs deploy/devzone-workspace-egress-proxy -c access-log -n <namespace>`.
455
+ - **Garde (strict)** : une fenêtre de 1 à 2 s existe au démarrage avant que la restriction soit programmée ; un conteneur d’initialisation attend que l’accès direct soit fermé (20 essais, 1 s) et refuse la session si la restriction ne devient jamais effective.
456
+ - **Limites** : le workspace lui-même reste ouvert ; seules les sessions `devzone agent --pod` sont filtrées ; les outils qui ignorent `HTTPS_PROXY` sont bloqués en mode strict.
@@ -0,0 +1,37 @@
1
+ {{- if and .Values.egressProxy.enabled (eq .Values.egressProxy.mode "strict") -}}
2
+ apiVersion: networking.k8s.io/v1
3
+ kind: NetworkPolicy
4
+ metadata:
5
+ name: {{ include "devzone-workspace.fullname" . }}-egress-strict
6
+ namespace: {{ .Release.Namespace }}
7
+ labels:
8
+ app.kubernetes.io/name: {{ include "devzone-workspace.name" . }}-egress-proxy
9
+ app.kubernetes.io/part-of: devzone
10
+ app.kubernetes.io/managed-by: devzone
11
+ app.kubernetes.io/component: egress-proxy
12
+ spec:
13
+ podSelector:
14
+ matchExpressions:
15
+ - key: devzone.io/agent-session
16
+ operator: Exists
17
+ policyTypes:
18
+ - Egress
19
+ egress:
20
+ - to:
21
+ - podSelector:
22
+ matchLabels:
23
+ app.kubernetes.io/name: {{ include "devzone-workspace.name" . }}-egress-proxy
24
+ app.kubernetes.io/component: egress-proxy
25
+ ports:
26
+ - protocol: TCP
27
+ port: 3128
28
+ - to:
29
+ - namespaceSelector:
30
+ matchLabels:
31
+ kubernetes.io/metadata.name: kube-system
32
+ ports:
33
+ - protocol: UDP
34
+ port: 53
35
+ - protocol: TCP
36
+ port: 53
37
+ {{- end -}}
@@ -0,0 +1,102 @@
1
+ {{- if .Values.egressProxy.enabled -}}
2
+ apiVersion: v1
3
+ kind: ConfigMap
4
+ metadata:
5
+ name: {{ include "devzone-workspace.fullname" . }}-egress-proxy
6
+ namespace: {{ .Release.Namespace }}
7
+ labels:
8
+ app.kubernetes.io/name: {{ include "devzone-workspace.name" . }}-egress-proxy
9
+ app.kubernetes.io/part-of: devzone
10
+ app.kubernetes.io/managed-by: devzone
11
+ app.kubernetes.io/component: egress-proxy
12
+ data:
13
+ squid.conf: |
14
+ http_port 3128
15
+ max_filedescriptors 1024
16
+ cache deny all
17
+ access_log daemon:/var/log/squid/access.log
18
+ pid_filename /tmp/squid.pid
19
+ {{- if eq .Values.egressProxy.mode "strict" }}
20
+ {{- range .Values.egressProxy.allowedDomains }}
21
+ acl allowed dstdomain {{ . }}
22
+ {{- end }}
23
+ acl SSL_ports port 443
24
+ acl CONNECT method CONNECT
25
+ http_access allow CONNECT SSL_ports allowed
26
+ http_access allow allowed
27
+ http_access deny all
28
+ {{- else }}
29
+ http_access allow all
30
+ {{- end }}
31
+ ---
32
+ apiVersion: apps/v1
33
+ kind: Deployment
34
+ metadata:
35
+ name: {{ include "devzone-workspace.fullname" . }}-egress-proxy
36
+ namespace: {{ .Release.Namespace }}
37
+ labels:
38
+ app.kubernetes.io/name: {{ include "devzone-workspace.name" . }}-egress-proxy
39
+ app.kubernetes.io/part-of: devzone
40
+ app.kubernetes.io/managed-by: devzone
41
+ app.kubernetes.io/component: egress-proxy
42
+ spec:
43
+ replicas: 1
44
+ selector:
45
+ matchLabels:
46
+ app.kubernetes.io/name: {{ include "devzone-workspace.name" . }}-egress-proxy
47
+ app.kubernetes.io/component: egress-proxy
48
+ template:
49
+ metadata:
50
+ labels:
51
+ app.kubernetes.io/name: {{ include "devzone-workspace.name" . }}-egress-proxy
52
+ app.kubernetes.io/part-of: devzone
53
+ app.kubernetes.io/managed-by: devzone
54
+ app.kubernetes.io/component: egress-proxy
55
+ spec:
56
+ volumes:
57
+ - name: config
58
+ configMap:
59
+ name: {{ include "devzone-workspace.fullname" . }}-egress-proxy
60
+ - name: logs
61
+ emptyDir: {}
62
+ containers:
63
+ - name: squid
64
+ image: {{ .Values.egressProxy.image }}
65
+ ports:
66
+ - name: proxy
67
+ containerPort: 3128
68
+ volumeMounts:
69
+ - name: config
70
+ mountPath: /etc/squid/squid.conf
71
+ subPath: squid.conf
72
+ - name: logs
73
+ mountPath: /var/log/squid
74
+ resources:
75
+ {{- toYaml .Values.egressProxy.resources | nindent 12 }}
76
+ - name: access-log
77
+ image: busybox:1.36
78
+ command: ["sh", "-c", "tail -F /var/log/squid/access.log 2>/dev/null"]
79
+ volumeMounts:
80
+ - name: logs
81
+ mountPath: /var/log/squid
82
+ ---
83
+ apiVersion: v1
84
+ kind: Service
85
+ metadata:
86
+ name: egress-proxy
87
+ namespace: {{ .Release.Namespace }}
88
+ labels:
89
+ app.kubernetes.io/name: {{ include "devzone-workspace.name" . }}-egress-proxy
90
+ app.kubernetes.io/part-of: devzone
91
+ app.kubernetes.io/managed-by: devzone
92
+ app.kubernetes.io/component: egress-proxy
93
+ devzone.io/egress-mode: {{ .Values.egressProxy.mode | quote }}
94
+ spec:
95
+ selector:
96
+ app.kubernetes.io/name: {{ include "devzone-workspace.name" . }}-egress-proxy
97
+ app.kubernetes.io/component: egress-proxy
98
+ ports:
99
+ - name: proxy
100
+ port: 3128
101
+ targetPort: 3128
102
+ {{- end -}}
@@ -97,3 +97,19 @@ networkPolicy:
97
97
  # workstation needs the Internet (Maven, npm, Docker images). true limits the
98
98
  # egress to the namespace and to DNS (kube-system). The egress allow list is #220.
99
99
  restrictEgress: false
100
+
101
+ egressProxy:
102
+ enabled: false
103
+ mode: observation
104
+ allowedDomains:
105
+ - .opencode.ai
106
+ - .npmjs.org
107
+ - .github.com
108
+ image: ubuntu/squid@sha256:6a097f68bae708cedbabd6188d68c7e2e7a38cedd05a176e1cc0ba29e3bbe029
109
+ resources:
110
+ requests:
111
+ memory: 64Mi
112
+ cpu: 50m
113
+ limits:
114
+ memory: 256Mi
115
+ cpu: "1"
@@ -85,13 +85,13 @@ services_argocd_toggle() {
85
85
  chart_require "$svc" || return $?
86
86
  echo "▶ $svc as an Argo CD Application (charts/devzone-$svc at $(argocd_revision))…"
87
87
  services_note "$svc" on
88
- services_reconcile
88
+ services_reconcile || return $?
89
89
  echo "✔ Application devzone-$svc declared ([services] $svc = on in $ARGOCD_CONF); status: devzone workspace argocd status; local access: devzone workspace ports"
90
90
  ;;
91
91
  disable)
92
92
  yes="$(yes_flag "services disable $svc [--yes]" "$@")" || return 1
93
93
  services_note "$svc" off
94
- services_reconcile
94
+ services_reconcile || return $?
95
95
  if [ "$yes" = 1 ]; then
96
96
  ak delete namespace "devzone-$svc" --wait=true --ignore-not-found >/dev/null
97
97
  case "$svc" in
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devzone",
3
- "version": "0.48.1",
3
+ "version": "0.49.0",
4
4
  "description": "Ton poste de développement Linux, prêt en une commande, identique sur Mac, Windows et Linux.",
5
5
  "license": "GPL-3.0-only",
6
6
  "repository": {