Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
File size: 8,970 Bytes
d15f07c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | ---
title: GSA .gov Domain Integration
---
# GSA .gov Domain Integration
## Overview
This document describes the integration of **GSA (General Services Administration) .gov domain data** into the `jurisdictions_details_search` table.
**Data Source:** https://github.com/cisagov/dotgov-data
**Type of Load:** **ENRICHMENT/UPDATE LOAD**
- Does **NOT** create new jurisdiction records
- **Adds** official .gov domain information to existing jurisdictions
- **Updates** records with GSA-verified government contact data
---
## Data Fields Added
### New Columns in `jurisdictions_details_search`
| Column | Type | Description |
|--------|------|-------------|
| `gov_domains` | JSONB | Array of all official .gov domains registered to this jurisdiction |
| `security_contact_email` | TEXT | Official security/technical contact email from GSA registry |
| `gsa_organization_name` | TEXT | Official organization name as registered with GSA |
| `gsa_domain_type` | TEXT | GSA classification (City, County, State, Special District, etc.) |
| `gsa_last_updated` | TIMESTAMP | When GSA data was last loaded |
### GSA Source Data Fields
The GSA dataset contains:
- **Domain name** (e.g., "bostonma.gov")
- **Domain type** (Federal, State, County, City, Township, Special District, School District)
- **Organization name** (official registered name)
- **Suborganization name** (departments, divisions)
- **City** (jurisdiction location)
- **State** (2-letter code)
- **Security contact email** (technical/security contact)
---
## Matching Strategy
### City Matching
Matches by **normalized city name + state code**:
```python
# Examples:
"Town of Abington, MA" -> normalized to "abington" + "MA"
"City of Boston, MA" -> normalized to "boston" + "MA"
```
Common prefixes removed during normalization:
- "City of "
- "Town of "
- "Village of "
- "Township of "
- "Borough of "
### County Matching
Matches by **county name + state code**:
```python
# Examples:
"King County, WA" -> normalized to "king county" + "WA"
"Suffolk County, MA" -> normalized to "suffolk county" + "MA"
```
---
## Coverage Statistics (6 Dev States)
### Overall Summary
- **Total jurisdictions checked:** 4,383
- **Matched with GSA domains:** 679 (15.5%)
- **No GSA match found:** 3,704 (84.5%)
### By State and Type
| State | Type | Total | With GSA | Coverage | With Contact Email |
|-------|------|-------|----------|----------|-------------------|
| **AL** | City | 594 | 115 | **19.4%** | 75 |
| AL | County | 67 | 0 | 0.0% | 0 |
| **GA** | City | 675 | 174 | **25.8%** | 104 |
| GA | County | 159 | 0 | 0.0% | 0 |
| **IN** | City | 976 | 85 | **8.7%** | 54 |
| IN | County | 92 | 0 | 0.0% | 0 |
| **MA** | City | 248 | 36 | **14.5%** | 29 |
| MA | County | 14 | 0 | 0.0% | 0 |
| **WA** | City | 639 | 124 | **19.4%** | 94 |
| WA | County | 39 | 0 | 0.0% | 0 |
| **WI** | City | 808 | 143 | **17.7%** | 102 |
| WI | County | 72 | 2 | 2.8% | 1 |
### Key Insights
Yes **Cities:** 8-26% have official .gov domains registered
- Best coverage: **Georgia (25.8%)**, **Alabama (19.4%)**, **Washington (19.4%)**
- Lowest coverage: **Indiana (8.7%)**
Warning **Counties:** Very low .gov domain registration
- Only **2 out of 443 counties** have .gov domains (0.5%)
- Counties typically use state-run websites or no dedicated domain
---
## Example Enriched Records
### City with Multiple Domains
```json
{
"jurisdiction_name": "Monroe",
"state_code": "WI",
"jurisdiction_type": "city",
"gov_domains": [
"cityofmonroewi.gov",
"pdmonroewi.gov",
"townofclarnowi.gov",
"townofjordanwi.gov",
"townofmonroewi.gov",
"townofsylvesterwi.gov"
],
"security_contact_email": "rjacobson@cityofmonroe.org",
"gsa_organization_name": "City of Monroe",
"gsa_domain_type": "City",
"website_url": "https://cityofmonroewi.gov"
}
```
### City with Security Contact
```json
{
"jurisdiction_name": "Beloit",
"state_code": "WI",
"jurisdiction_type": "city",
"gov_domains": [
"beloitwi.gov",
"newarkwi.gov",
"townofbeloitwi.gov",
"townofturtlewi.gov"
],
"security_contact_email": "adminnotification@beloitwi.gov",
"gsa_organization_name": "City of Beloit",
"gsa_domain_type": "City"
}
```
---
## Scripts
### Main Loading Script
**File:** `scripts/datasources/gsa/load_gsa_domains_to_postgres.py`
**Usage:**
```bash
# Load all states
python scripts/datasources/gsa/load_gsa_domains_to_postgres.py
# Load specific states
python scripts/datasources/gsa/load_gsa_domains_to_postgres.py --states AL,GA,MA,WA
# Dry run (preview without updating)
python scripts/datasources/gsa/load_gsa_domains_to_postgres.py --states AL,GA --dry-run
```
**Features:**
- Yes Downloads latest GSA data from GitHub (cached for 24 hours)
- Yes Normalizes jurisdiction names for matching
- Yes Batch updates with ON CONFLICT handling
- Yes Dry-run mode for testing
- Yes Comprehensive statistics and logging
### Database Schema Updates
```sql
-- Add columns (idempotent)
ALTER TABLE jurisdictions_details_search
ADD COLUMN IF NOT EXISTS gov_domains JSONB DEFAULT '[]',
ADD COLUMN IF NOT EXISTS security_contact_email TEXT,
ADD COLUMN IF NOT EXISTS gsa_organization_name TEXT,
ADD COLUMN IF NOT EXISTS gsa_domain_type TEXT,
ADD COLUMN IF NOT EXISTS gsa_last_updated TIMESTAMP;
-- Create index for domain lookups
CREATE INDEX IF NOT EXISTS idx_jurisdiction_details_gov_domains
ON jurisdictions_details_search USING gin(gov_domains);
```
---
## Use Cases
### 1. Find Jurisdictions with Official Government Domains
```sql
SELECT
jurisdiction_name,
state_code,
gov_domains,
website_url
FROM jurisdictions_details_search
WHERE jsonb_array_length(gov_domains) > 0
ORDER BY state_code, jurisdiction_name;
```
### 2. Get Security Contact for a Jurisdiction
```sql
SELECT
jurisdiction_name,
security_contact_email,
gsa_organization_name
FROM jurisdictions_details_search
WHERE jurisdiction_name ILIKE '%boston%'
AND state_code = 'MA';
```
### 3. Find Jurisdictions with Multiple Domains
```sql
SELECT
jurisdiction_name,
state_code,
jsonb_array_length(gov_domains) as domain_count,
gov_domains
FROM jurisdictions_details_search
WHERE jsonb_array_length(gov_domains) > 3
ORDER BY domain_count DESC;
```
### 4. Validate Website URLs Against GSA Registry
```sql
SELECT
jurisdiction_name,
website_url,
gov_domains,
CASE
WHEN website_url IS NULL THEN 'No website'
WHEN gov_domains ? REPLACE(REPLACE(website_url, 'https://', ''), 'http://', '') THEN 'GSA verified'
ELSE 'Not in GSA registry'
END as verification_status
FROM jurisdictions_details_search
WHERE jsonb_array_length(gov_domains) > 0
LIMIT 20;
```
---
## Limitations
### Low County Coverage
- **Only 0.5% of counties** have registered .gov domains
- Most counties use state-operated websites (e.g., `county.state.gov`)
- Some counties have no dedicated web presence
### City Name Variations
Some jurisdictions may not match due to:
- Inconsistent naming (GSA: "City of X" vs Census: "X city")
- Merged jurisdictions (one domain, multiple census places)
- Special characters or apostrophes
### Domain Ownership
- GSA data shows **registered** domains, not necessarily **active** websites
- Some domains may redirect to other sites
- Multiple domains may point to the same website
---
## Maintenance
### Update Frequency
- GSA updates the domain list **continuously** as new domains are registered
- Recommend running enrichment load: **Monthly** or **Quarterly**
- Cache is valid for **24 hours** to avoid excessive downloads
### Re-running the Load
The load is **idempotent** and safe to re-run:
```bash
# Updates existing records with latest GSA data
python scripts/datasources/gsa/load_gsa_domains_to_postgres.py --states AL,GA,IN,MA,WA,WI
```
### Monitoring
Check for stale data:
```sql
SELECT
state_code,
COUNT(*) as jurisdictions_with_gsa,
MAX(gsa_last_updated) as most_recent_update,
MIN(gsa_last_updated) as oldest_update
FROM jurisdictions_details_search
WHERE gov_domains IS NOT NULL
GROUP BY state_code
ORDER BY state_code;
```
---
## Next Steps
### Potential Enhancements
1. **Expand to All 50 States**
```bash
python scripts/datasources/gsa/load_gsa_domains_to_postgres.py
# (no --states filter = all states)
```
2. **Domain Validation**
- Check if domains are actually active (HTTP status)
- Verify SSL certificates
- Update `website_url` with verified primary domain
3. **County Domain Discovery**
- Scrape state government portals for county websites
- Check for `<county-name>.<state>.gov` patterns
- Alternative sources: Wikipedia, county associations
4. **Integration with YouTube Discovery**
- Cross-reference .gov domains with YouTube channel URLs
- Identify official government channels
- Flag non-governmental channels
---
## References
- **GSA Domain Data:** https://github.com/cisagov/dotgov-data
- **GSA .gov Registry:** https://get.gov/
- **CISA Domain Security:** https://www.cisa.gov/topics/cyber-threats-and-advisories/federal-network-resilience/dotgov-program
|