File tree Expand file tree Collapse file tree 6 files changed +55
-7
lines changed
Expand file tree Collapse file tree 6 files changed +55
-7
lines changed Original file line number Diff line number Diff line change 66 branches : [ master ]
77jobs :
88 test :
9- runs-on : ubuntu-latest
9+ runs-on : ubuntu-20.04
1010 timeout-minutes : 60
1111 steps :
1212 - uses : microsoft/playwright-github-action@v1
4545 if : ${{ failure() }}
4646 uses : mxschmitt/action-tmate@v3
4747 lint :
48- runs-on : ubuntu-latest
48+ runs-on : ubuntu-20.04
4949 strategy :
5050 fail-fast : false
5151 matrix :
6767 run : npm run build
6868 build :
6969 # needs: test
70- runs-on : ubuntu-latest
70+ runs-on : ubuntu-20.04
7171 if : github.event_name == 'push'
7272 strategy :
7373 fail-fast : false
Original file line number Diff line number Diff line change @@ -143,15 +143,16 @@ func (w *Worker) createPod() error {
143143 ObjectMeta : metav1.ObjectMeta {
144144 GenerateName : "worker-" ,
145145 Labels : map [string ]string {
146- "pod-name " : "nginx " ,
146+ "role " : "worker " ,
147147 },
148148 },
149149 Spec : v1.PodSpec {
150150 RestartPolicy : v1 .RestartPolicy (v1 .RestartPolicyNever ),
151151 Containers : []v1.Container {
152152 {
153- Name : "worker" ,
154- Image : "ghcr.io/mxschmitt/try-playwright/worker:latest" ,
153+ Name : "worker" ,
154+ Image : "ghcr.io/mxschmitt/try-playwright/worker:latest" ,
155+ ImagePullPolicy : v1 .PullIfNotPresent ,
155156 Env : []v1.EnvVar {
156157 {
157158 Name : "WORKER_ID" ,
Original file line number Diff line number Diff line change @@ -177,4 +177,25 @@ const playwright = require("playwright");
177177 await page . click ( "text='Run'" )
178178 await page . waitForSelector ( "text='Error: foobar!'" )
179179 } )
180+ it ( "should prevent access to the control microservice from inside the worker" , async ( { page } ) => {
181+ await page . goto ( ROOT_URL ) ;
182+ await page . waitForTimeout ( 200 )
183+ await page . evaluate ( ( ) => {
184+ // @ts -ignore
185+ window . monacoEditorModel . setValue ( `// @ts-check
186+ const playwright = require('playwright');
187+
188+ (async () => {
189+ const browser = await playwright.chromium.launch();
190+ const page = await browser.newPage();
191+ await page.goto('http://control:8080/service/control/health');
192+ await browser.close();
193+ })();` )
194+ } )
195+ await page . waitForTimeout ( 200 )
196+ await Promise . all ( [
197+ page . waitForSelector ( "text=ERR_CONNECTION_REFUSED" ) ,
198+ page . click ( "text='Run'" )
199+ ] )
200+ } )
180201} )
Original file line number Diff line number Diff line change 2929 value : https://c4698982912c457ba9c9a2a815a8bb25@o359550.ingest.sentry.io/5479806
3030 image : ghcr.io/mxschmitt/try-playwright/control-service:latest
3131 name : control
32- imagePullPolicy : Always
32+ imagePullPolicy : IfNotPresent
3333 restartPolicy : Always
Original file line number Diff line number Diff line change 1313 metadata :
1414 labels :
1515 io.kompose.service : file
16+ reachable-by-worker : " true"
1617 spec :
1718 containers :
1819 - env :
Original file line number Diff line number Diff line change 1+ apiVersion : networking.k8s.io/v1
2+ kind : NetworkPolicy
3+ metadata :
4+ name : deny-worker-traffic
5+ spec :
6+ podSelector :
7+ matchLabels :
8+ role : worker
9+ egress :
10+ - to :
11+ - ipBlock :
12+ cidr : 0.0.0.0/0
13+ except :
14+ - 10.0.0.0/8
15+ - 192.168.0.0/16
16+ - 172.16.0.0/20
17+ - podSelector :
18+ matchLabels :
19+ reachable-by-worker : " true"
20+ - to :
21+ ports :
22+ - protocol : TCP
23+ port : 53
24+ - protocol : UDP
25+ port : 53
You can’t perform that action at this time.
0 commit comments