Skip to content

Commit caa322c

Browse files
Make port visibility private by default
1 parent 2f7cc15 commit caa322c

File tree

10 files changed

+17
-20
lines changed

10 files changed

+17
-20
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file.
44

55
## June 2021
66

7+
- Breaking Change: Make ports configured in `.gitpod.yml` private by default when no value for `visibility` is given (was public). This change is for security reasons. ([#4548](https://github.com/gitpod-io/gitpod/pull/4548))
78
- Fix active workspace list in dashboard (show also older pinned workspaces) ([#4523](https://github.com/gitpod-io/gitpod/pull/4523))
89
- Adding `ItemsList` component as a more maintainable and consistent way to render a list of workspaces, git integrations, environment variables, etc. ([#4454](https://github.com/gitpod-io/gitpod/pull/4454))
910
- Improve backup stability when pods get evicted ([#4405](https://github.com/gitpod-io/gitpod/pull/4405))

components/gitpod-protocol/data/gitpod-schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
"private",
3535
"public"
3636
],
37-
"default": "public",
38-
"description": "Whether the port visibility should be private or public. 'public' (default) will allow everyone with the port URL to access the port. 'private' will only allow users with workspace access to access the port."
37+
"default": "private",
38+
"description": "Whether the port visibility should be private or public. 'private' (default) will only allow users with workspace access to access the port. 'public' will allow everyone with the port URL to access the port."
3939
},
4040
"name": {
4141
"type": "string",

components/server/src/workspace/gitpod-server-impl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1073,9 +1073,9 @@ export class GitpodServerImpl<Client extends GitpodClient, Server extends Gitpod
10731073

10741074
protected portVisibilityToProto(visibility: PortVisibility | undefined): ProtoPortVisibility {
10751075
switch (visibility) {
1076+
default: // the default for requests is: private
10761077
case 'private':
10771078
return ProtoPortVisibility.PORT_VISIBILITY_PRIVATE;
1078-
default: // the default for requests is: public
10791079
case 'public':
10801080
return ProtoPortVisibility.PORT_VISIBILITY_PUBLIC;
10811081
}

components/server/src/workspace/workspace-starter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ export class WorkspaceStarter {
606606

607607
spec.setPort(p.port);
608608
spec.setTarget(target);
609-
spec.setVisibility(p.visibility == 'private' ? PortVisibility.PORT_VISIBILITY_PRIVATE : PortVisibility.PORT_VISIBILITY_PUBLIC);
609+
spec.setVisibility(p.visibility == 'public' ? PortVisibility.PORT_VISIBILITY_PUBLIC : PortVisibility.PORT_VISIBILITY_PRIVATE);
610610
return spec;
611611
}).filter(spec => !!spec) as PortSpec[];
612612

components/supervisor/pkg/ports/ports.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,9 @@ func (pm *Manager) nextState(ctx context.Context) map[uint32]*managedPort {
342342
return
343343
}
344344
mp.GlobalPort = port
345-
mp.Visibility = api.PortVisibility_public
346-
if config.Visibility == "private" {
347-
mp.Visibility = api.PortVisibility_private
345+
mp.Visibility = api.PortVisibility_private
346+
if config.Visibility == "public" {
347+
mp.Visibility = api.PortVisibility_public
348348
}
349349
public := mp.Visibility == api.PortVisibility_public
350350
pm.autoExpose(ctx, mp, public)
@@ -396,7 +396,7 @@ func (pm *Manager) nextState(ctx context.Context) map[uint32]*managedPort {
396396
if mp.Exposed || configured {
397397
public = mp.Visibility == api.PortVisibility_public
398398
} else {
399-
public = exists && config.Visibility != "private"
399+
public = exists && config.Visibility == "public"
400400
}
401401

402402
pm.autoExpose(ctx, mp, public)

components/supervisor/pkg/ports/ports_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func TestPortsUpdateState(t *testing.T) {
128128
},
129129
},
130130
ExpectedExposure: []ExposedPort{
131-
{LocalPort: 8080, GlobalPort: 8080, Public: true},
131+
{LocalPort: 8080, GlobalPort: 8080},
132132
{LocalPort: 9229, GlobalPort: 9229},
133133
{LocalPort: 9229, GlobalPort: 60000},
134134
},
@@ -159,7 +159,7 @@ func TestPortsUpdateState(t *testing.T) {
159159
{Served: []ServedPort{{"0100007F", 4040, true}, {"00000000", 60000, false}}},
160160
},
161161
ExpectedExposure: []ExposedPort{
162-
{LocalPort: 4040, GlobalPort: 60000, Public: true},
162+
{LocalPort: 4040, GlobalPort: 60000},
163163
},
164164
ExpectedUpdates: UpdateExpectation{
165165
{},

components/ws-manager/pkg/manager/manager.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -750,14 +750,14 @@ func portNameToVisibility(s string) api.PortVisibility {
750750
parts := strings.Split(s, "-")
751751
if len(parts) != 2 {
752752
// old or wrong port name: return default
753-
return api.PortVisibility_PORT_VISIBILITY_PUBLIC
753+
return api.PortVisibility_PORT_VISIBILITY_PRIVATE
754754
}
755755

756756
// parse (or public as fallback: important for backwards compatibility during rollout)
757757
visibilitStr := fmt.Sprintf("PORT_VISIBILITY_%s", strings.ToUpper(parts[1]))
758758
i32Value, present := api.PortVisibility_value[visibilitStr]
759759
if !present {
760-
return api.PortVisibility_PORT_VISIBILITY_PUBLIC
760+
return api.PortVisibility_PORT_VISIBILITY_PRIVATE
761761
}
762762
return api.PortVisibility(i32Value)
763763
}

components/ws-manager/pkg/manager/testdata/status_interrupted.golden

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@
1414
"exposed_ports": [
1515
{
1616
"port": 5900,
17-
"target": 35900,
18-
"visibility": 1
17+
"target": 35900
1918
},
2019
{
2120
"port": 8080,
22-
"target": 38080,
23-
"visibility": 1
21+
"target": 38080
2422
}
2523
]
2624
},

components/ws-manager/pkg/manager/testdata/status_regularStart_Initializing00.golden

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
"url": "http://10.0.0.114:8082",
1414
"exposed_ports": [
1515
{
16-
"port": 8080,
17-
"visibility": 1
16+
"port": 8080
1817
}
1918
]
2019
},

components/ws-manager/pkg/manager/testdata/status_wsstartup_Creating00.golden

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
"url": "http://10.0.0.114:8082",
1414
"exposed_ports": [
1515
{
16-
"port": 8080,
17-
"visibility": 1
16+
"port": 8080
1817
}
1918
]
2019
},

0 commit comments

Comments
 (0)