Skip to content

Add hosts file validation for mappings#67

Draft
evg4b wants to merge 3 commits into
mainfrom
feature/validate-hosts-in-mappings
Draft

Add hosts file validation for mappings#67
evg4b wants to merge 3 commits into
mainfrom
feature/validate-hosts-in-mappings

Conversation

@evg4b
Copy link
Copy Markdown
Owner

@evg4b evg4b commented Oct 27, 2025

  • Add hosts file reader to check system hosts file entries
  • Add validator to check that hosts from mappings point to localhost
  • Display warning if mapping host is not found in hosts file
  • Skip wildcard hostnames in validation
  • Add tests for hosts reader and validator

Description

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Code refactoring
  • Test update
  • Chore (dependency updates, CI/CD changes, etc.)

Related Issues

Motivation and Context

How Has This Been Tested?

  • Unit tests
  • Integration tests
  • Manual testing
  • Added new tests

Test Configuration:

  • Go version:
  • OS:
  • UNCORS version:

Screenshots (if applicable)

Checklist

Code Quality

  • My code follows the code style of this project
  • I have run make format to format my code
  • I have run golangci-lint run and resolved all issues
  • I have performed a self-review of my code
  • My code has no new warnings or errors

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have run make test and all tests pass
  • I have run make test-cover and maintained or improved code coverage

Documentation

  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have updated the wiki if necessary
  • I have updated the JSON schema if configuration changes were made

Dependencies

  • My changes don't introduce new dependencies, or they are justified
  • I have run go mod tidy to clean up dependencies
  • All dependencies are compatible with the project's Go version

Breaking Changes

  • This PR contains breaking changes
  • I have updated the migration guide (if applicable)
  • I have clearly documented breaking changes in the PR description

Additional Notes

For Reviewers

Areas that need special attention:

Known issues or limitations:


By submitting this pull request, I confirm that my contribution is made under the terms of the MIT License and I have read and followed the Contributing Guidelines.

@evg4b evg4b force-pushed the feature/validate-hosts-in-mappings branch from 5df326d to dd38c7c Compare October 27, 2025 13:45
@evg4b evg4b marked this pull request as draft October 27, 2025 13:45
evg4b added 3 commits October 29, 2025 20:24
- Add hosts file reader to check system hosts file entries
- Add validator to check that hosts from mappings point to localhost
- Display warning if mapping host is not found in hosts file
- Skip wildcard hostnames in validation
- Add tests for hosts reader and validator
- Use afero.Fs instead of direct os.Open for better testability
- Pass filesystem as dependency to ReadHostsFile and ValidateHostsFileEntries
- Add comprehensive tests using afero.MemMapFs
- Improve test coverage with mock filesystem scenarios
- Add constant for minimum hosts file fields to fix magic number warning
- Use require.Error instead of assert.Error for error assertions
- Add test case with different hosts file content to fix unparam warning
- Add test case for existing host in hosts file
@evg4b evg4b force-pushed the feature/validate-hosts-in-mappings branch from dd38c7c to f9edc48 Compare October 30, 2025 00:24
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
3 Security Hotspots

See analysis details on SonarQube Cloud

@evg4b evg4b force-pushed the main branch 2 times, most recently from 5711115 to ff88be9 Compare November 9, 2025 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant