INNER CODE UNIT · Go

TestSanitizePrivateIPs

projectdiscovery/cloudlist · internal/runner/runner_test.go:9

func TestSanitizePrivateIPs(t *testing.T) {
	resource := &schema.Resource{
		PublicIPv4:  "1.2.3.4",
		PrivateIpv4: "10.0.0.5",
		PrivateIpv6: "fd00::1",
		PublicIPv6:  "2606:4700:4700::1111",
		DNSName:     "example.internal",
	}

	sanitizePrivateIPs(resource, true)

	if resource.PrivateIpv4 != "" || resource.PrivateIpv6 != "" {
		t.Fatalf("expected private addresses to be cleared, got %q and %q", resource.PrivateIpv4, resource.PrivateIpv6)
	}

	if resource.PublicIPv4 == "" || resource.PublicIPv6 == "" || resource.DNSName == "" {
		t.Fatalf("public fields should remain untouched: %+v", resource)
	}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…