Skip to content

Conversation

@ryancdotorg
Copy link
Contributor

This patch enhances downloading of hosts files/blocklists by adding support for conditional download based on ETag or Date headers.

Temporary files are also now used when downloading hosts files/blocklists.

return nil, fmt.Errorf("error downloading source: %s %s", uri, err)
}

current, err := os.ReadFile(filePath)

Check failure

Code scanning / gosec

Potential file inclusion via variable Error

Potential file inclusion via variable
// header with an ETag and If-Modified-Since with a Date are set, the
// latter is supposed to be ignored, but not all servers work like that.
if etag := response.Header.Get("ETag"); etag != "" {
output.WriteString(fmt.Sprintf("# ETag: %s\n", etag))

Check warning

Code scanning / gosec

Errors unhandled. Warning

Errors unhandled.
if etag := response.Header.Get("ETag"); etag != "" {
output.WriteString(fmt.Sprintf("# ETag: %s\n", etag))
} else if date := response.Header.Get("Date"); date != "" {
output.WriteString(fmt.Sprintf("# Date: %s\n", date))

Check warning

Code scanning / gosec

Errors unhandled. Warning

Errors unhandled.
output.WriteString(fmt.Sprintf("# Date: %s\n", date))
}

output.WriteString("\n")

Check warning

Code scanning / gosec

Errors unhandled. Warning

Errors unhandled.
logger.Criticalf("Error closing file: %s\n", err)
}

if err := os.Chmod(tempPath, 0o644); err != nil {

Check failure

Code scanning / gosec

Expect file permissions to be 0600 or less Error

Expect file permissions to be 0600 or less
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