From d364e86334142953019320604cb7db06c74fdb2f Mon Sep 17 00:00:00 2001 From: Steven Masley Date: Thu, 7 Dec 2023 16:15:10 -0600 Subject: [PATCH 1/2] chore: check if process is nil We check if process is nil in the ports_supported file. Just matching that defensive check, not sure if it can be nil. --- agent/agentssh/portinspection_supported.go | 6 ++++++ .../testdata/genericunion/genericunion.go | 18 ++++++++++++++++++ .../testdata/genericunion/genericunion.ts | 0 3 files changed, 24 insertions(+) create mode 100644 scripts/apitypings/testdata/genericunion/genericunion.go create mode 100644 scripts/apitypings/testdata/genericunion/genericunion.ts diff --git a/agent/agentssh/portinspection_supported.go b/agent/agentssh/portinspection_supported.go index 45f59accc40f6..d45847bd6f0b6 100644 --- a/agent/agentssh/portinspection_supported.go +++ b/agent/agentssh/portinspection_supported.go @@ -20,6 +20,12 @@ func getListeningPortProcessCmdline(port uint32) (string, error) { if len(tabs) == 0 { return "", nil } + + // Defensive check. + if tabs[0].Process == nil { + return "", nil + } + // The process name provided by go-netstat does not include the full command // line so grab that instead. pid := tabs[0].Process.Pid diff --git a/scripts/apitypings/testdata/genericunion/genericunion.go b/scripts/apitypings/testdata/genericunion/genericunion.go new file mode 100644 index 0000000000000..a7662b3bb54c2 --- /dev/null +++ b/scripts/apitypings/testdata/genericunion/genericunion.go @@ -0,0 +1,18 @@ +package codersdk + +type Region struct { + ID string `json:"id" format:"uuid" table:"id"` +} +type WorkspaceProxy struct { + // Extends Region with extra information + Region `table:"region,recursive_inline"` + DerpOnly bool `json:"derp_only" table:"derp_only"` +} + +type RegionTypes interface { + Region | WorkspaceProxy +} + +type RegionsResponse[R RegionTypes] struct { + Regions []R `json:"regions"` +} diff --git a/scripts/apitypings/testdata/genericunion/genericunion.ts b/scripts/apitypings/testdata/genericunion/genericunion.ts new file mode 100644 index 0000000000000..e69de29bb2d1d From 4dba8fec9403dcd9c764faecf8b64c46d5e0ebbb Mon Sep 17 00:00:00 2001 From: Steven Masley Date: Thu, 7 Dec 2023 16:16:19 -0600 Subject: [PATCH 2/2] Whoops, remove some WIP stuff --- .../testdata/genericunion/genericunion.go | 18 ------------------ .../testdata/genericunion/genericunion.ts | 0 2 files changed, 18 deletions(-) delete mode 100644 scripts/apitypings/testdata/genericunion/genericunion.go delete mode 100644 scripts/apitypings/testdata/genericunion/genericunion.ts diff --git a/scripts/apitypings/testdata/genericunion/genericunion.go b/scripts/apitypings/testdata/genericunion/genericunion.go deleted file mode 100644 index a7662b3bb54c2..0000000000000 --- a/scripts/apitypings/testdata/genericunion/genericunion.go +++ /dev/null @@ -1,18 +0,0 @@ -package codersdk - -type Region struct { - ID string `json:"id" format:"uuid" table:"id"` -} -type WorkspaceProxy struct { - // Extends Region with extra information - Region `table:"region,recursive_inline"` - DerpOnly bool `json:"derp_only" table:"derp_only"` -} - -type RegionTypes interface { - Region | WorkspaceProxy -} - -type RegionsResponse[R RegionTypes] struct { - Regions []R `json:"regions"` -} diff --git a/scripts/apitypings/testdata/genericunion/genericunion.ts b/scripts/apitypings/testdata/genericunion/genericunion.ts deleted file mode 100644 index e69de29bb2d1d..0000000000000