|
| 1 | +# Snyk Connectivity Check Extension |
| 2 | + |
| 3 | +A Go-based extension for the Snyk CLI that performs comprehensive network connectivity diagnostics. This tool helps troubleshoot connectivity issues between your environment and Snyk's services. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Comprehensive Endpoint Testing**: Tests connectivity to all Snyk API endpoints and services |
| 8 | +- **Proxy Detection & Validation**: Automatically detects and validates proxy configurations |
| 9 | +- **Organization Listing**: Displays your Snyk organizations when authenticated (with default organization highlighted) |
| 10 | +- **Multiple Output Formats**: Human-readable (with color support) and JSON formats |
| 11 | +- **Actionable Diagnostics**: Provides specific recommendations based on connectivity issues |
| 12 | +- **Integration Ready**: Built as a workflow extension for the Snyk CLI using go-application-framework |
| 13 | + |
| 14 | +### Environment Variables |
| 15 | + |
| 16 | +The tool respects standard proxy environment variables: |
| 17 | +- `HTTPS_PROXY` / `https_proxy` |
| 18 | +- `HTTP_PROXY` / `http_proxy` |
| 19 | +- `NO_PROXY` / `no_proxy` |
| 20 | + |
| 21 | +For custom certificates: |
| 22 | +- `NODE_EXTRA_CA_CERTS` - Path to additional CA certificates bundle |
| 23 | + |
| 24 | +### Authentication |
| 25 | + |
| 26 | +The tool uses Snyk authentication from the go-application-framework configuration: |
| 27 | +- API tokens via `snyk auth` |
| 28 | +- OAuth tokens |
| 29 | +- Bearer tokens |
| 30 | + |
| 31 | +When authenticated, the tool will display your organizations with their IDs. The default organization is highlighted with a `[DEFAULT]` marker. |
| 32 | + |
| 33 | +### Command Line Options |
| 34 | + |
| 35 | +- `--json` - Output results in JSON format |
| 36 | +- `--no-color` - Disable colored output |
| 37 | +- `--timeout <seconds>` - Timeout in seconds for each connection test (default: 10) |
| 38 | +- `--max-org-count <number>` - Maximum number of organizations to retrieve (default: 100) |
| 39 | + |
| 40 | +## Output Examples |
| 41 | + |
| 42 | +### Human-Readable Output |
| 43 | + |
| 44 | +``` |
| 45 | +Checking for proxy configuration... |
| 46 | +
|
| 47 | +Environment variables: |
| 48 | + HTTPS_PROXY: (not set) |
| 49 | + https_proxy: (not set) |
| 50 | + HTTP_PROXY: (not set) |
| 51 | + http_proxy: (not set) |
| 52 | + NO_PROXY: (not set) |
| 53 | + no_proxy: (not set) |
| 54 | +
|
| 55 | +ℹ No proxy detected - Testing direct connection... |
| 56 | +
|
| 57 | +Testing connectivity to Snyk endpoints... |
| 58 | +
|
| 59 | +Host Result |
| 60 | +---------------------------------------------------------------------- |
| 61 | +api.snyk.io OK (HTTP 204) |
| 62 | +app.snyk.io OK (HTTP 200) |
| 63 | +api.eu.snyk.io OK (HTTP 204) |
| 64 | +app.eu.snyk.io OK (HTTP 200) |
| 65 | +api.us.snyk.io OK (HTTP 204) |
| 66 | +app.us.snyk.io OK (HTTP 200) |
| 67 | +api.au.snyk.io OK (HTTP 204) |
| 68 | +app.au.snyk.io OK (HTTP 200) |
| 69 | +api.snykgov.io OK (HTTP 204) |
| 70 | +app.snykgov.io OK (HTTP 200) |
| 71 | +deeproxy.snyk.io/filters OK (HTTP 200) |
| 72 | +downloads.snyk.io:443/cli/wasm/bundle.tar.gz OK (HTTP 200) |
| 73 | +learn.snyk.io OK (HTTP 200) |
| 74 | +static.snyk.io/cli/latest/version OK (HTTP 200) |
| 75 | +snyk.io OK (HTTP 200) |
| 76 | +sentry.io REACHABLE (HTTP 405) |
| 77 | +
|
| 78 | +--- Actionable TODOs --- |
| 79 | +All checks passed. Your network configuration appears to be compatible with Snyk CLI. |
| 80 | +
|
| 81 | +ℹ Certificate Configuration: |
| 82 | +If you need to trust custom certificates, set NODE_EXTRA_CA_CERTS environment variable |
| 83 | +pointing to your CA bundle file. |
| 84 | +
|
| 85 | +--- Snyk Token and Organizations --- |
| 86 | +✓ Authentication token is configured |
| 87 | +
|
| 88 | +Found 2 organizations: |
| 89 | +Group ID Org ID Name Slug Default |
| 90 | +--------------------------------------------------------------------------------------------------------------------------------------- |
| 91 | +a1b2c3d4-e5f6-7890-abcd-ef1234567890 d4e5f6a7-b890-cdef-1234-567890abcdef My Organization my-organization Yes |
| 92 | +b2c3d4e5-f6a7-8901-bcde-f23456789012 e5f6a7b8-c901-def2-3456-7890abcdef12 Another Org another-org |
| 93 | +``` |
| 94 | + |
| 95 | +### JSON Output |
| 96 | + |
| 97 | +```bash |
| 98 | +snyk connectivity-check --json |
| 99 | +``` |
| 100 | + |
| 101 | +```json |
| 102 | +{ |
| 103 | + "proxyConfig": { |
| 104 | + "detected": false, |
| 105 | + "url": "", |
| 106 | + "variable": "" |
| 107 | + }, |
| 108 | + "hostResults": [ |
| 109 | + { |
| 110 | + "host": "api.snyk.io", |
| 111 | + "displayHost": "api.snyk.io", |
| 112 | + "url": "https://api.snyk.io", |
| 113 | + "statusCode": 204, |
| 114 | + "status": 0, |
| 115 | + "responseTime": 150000000 |
| 116 | + } |
| 117 | + ], |
| 118 | + "todos": [], |
| 119 | + "organizations": [ |
| 120 | + { |
| 121 | + "id": "org-uuid-1", |
| 122 | + "groupId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", |
| 123 | + "name": "My Organization", |
| 124 | + "slug": "my-organization", |
| 125 | + "isDefault": true |
| 126 | + }, |
| 127 | + { |
| 128 | + "id": "org-uuid-2", |
| 129 | + "groupId": "b2c3d4e5-f6a7-8901-bcde-f23456789012", |
| 130 | + "name": "Another Org", |
| 131 | + "slug": "another-org", |
| 132 | + "isDefault": false |
| 133 | + } |
| 134 | + ], |
| 135 | + "tokenPresent": true, |
| 136 | + "startTime": "2024-01-15T10:00:00Z", |
| 137 | + "endTime": "2024-01-15T10:00:05Z" |
| 138 | +} |
| 139 | +``` |
| 140 | + |
| 141 | +## Troubleshooting |
| 142 | + |
| 143 | +### Common Issues |
| 144 | + |
| 145 | +#### Proxy Authentication Required |
| 146 | +If you see "PROXY AUTH REQUIRED", the tool has detected your proxy but needs authentication: |
| 147 | +- For NTLM/Negotiate proxies: The Snyk CLI supports these authentication methods |
| 148 | +- For other proxy auth types: Configure proxy credentials in your proxy URL |
| 149 | + |
| 150 | +#### DNS Errors |
| 151 | +If you see "DNS_ERROR" for multiple hosts: |
| 152 | +- Check your DNS configuration |
| 153 | +- Verify you can resolve external domains |
| 154 | +- Check if you need to use a corporate DNS server |
| 155 | + |
| 156 | +#### TLS/SSL Errors |
| 157 | +If you see "TLS/SSL_ERROR": |
| 158 | +- You may need to configure custom CA certificates |
| 159 | +- Set `NODE_EXTRA_CA_CERTS` to point to your CA bundle |
| 160 | +- Ensure your proxy (if any) isn't intercepting SSL |
| 161 | + |
| 162 | +#### No Organizations Displayed |
| 163 | +If authenticated but no organizations shown: |
| 164 | +- Verify your token has the correct permissions |
| 165 | +- Check if you belong to any organizations |
| 166 | +- Try re-authenticating with `snyk auth` |
| 167 | + |
| 168 | +### Status Meanings |
| 169 | + |
| 170 | +- **OK**: Full connectivity verified |
| 171 | +- **REACHABLE**: Host is reachable but returned unexpected status |
| 172 | +- **BLOCKED**: Connection refused or blocked |
| 173 | +- **DNS_ERROR**: Cannot resolve hostname |
| 174 | +- **TLS/SSL_ERROR**: Certificate or TLS handshake issues |
| 175 | +- **TIMEOUT**: Connection timed out |
| 176 | +- **PROXY AUTH REQUIRED (SUPPORTED)**: Proxy needs auth, type is supported |
| 177 | +- **PROXY AUTH REQUIRED (UNSUPPORTED)**: Proxy needs auth, type not supported |
0 commit comments