Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSV plugin fails to list the files from a HTTP URL #560

Closed
Subhajit97 opened this issue May 31, 2023 · 0 comments · Fixed by #567
Closed

CSV plugin fails to list the files from a HTTP URL #560

Subhajit97 opened this issue May 31, 2023 · 0 comments · Fixed by #567
Assignees
Labels
bug Something isn't working

Comments

@Subhajit97
Copy link
Contributor

In the CSV plugin, If we configure the path with an HTTP URL, for example:

connection "csv" {
  plugin = "csv"
  paths  = ["https://www.cisa.gov/sites/default/files/csv/known_exploited_vulnerabilities.csv"]
  # paths = ["http://surl.li/hkxeb"]
}

We are getting the below error:

[ERROR] steampipe-plugin-csv.plugin: [ERROR] csv.csvList: failed to fetch absolute path="failed to get directory specified by the source https://www.cisa.gov/sites/default/files/csv/known_exploited_vulnerabilities.csv: error downloading 'https://www.cisa.gov/sites/default/files/csv/known_exploited_vulnerabilities.csv': XML syntax error on line 147: expected /> in element"

We have tried this URL with a sample go-getter code snippet, and it throws the same error.

I have tried to update the GetFiles function (where we implemented the go-getter functionality). Currently, it uses the Get method defined in the go-getter library.

I tried to update it to use GetAny method instead of Get, and the above URL works fine. But the S3 URLs we currently use fail in that case.

Issue link: hashicorp/go-getter#438

Considering a temporary workaround, maybe we can use something like the below?

// use GetAny for any https or http URL
// and, for other case use the Get method
if strings.HasPrefix(remoteSourcePath, "https://") || strings.HasPrefix(remoteSourcePath, "http://") {
	err = getter.GetAny(dest, remoteSourcePath)
	if err != nil {
		return "", "", fmt.Errorf("failed to get directory specified by the source %s: %s", remoteSourcePath, err.Error())
	}
} else {
	err = getter.Get(dest, remoteSourcePath)
	if err != nil {
		return "", "", fmt.Errorf("failed to get directory specified by the source %s: %s", remoteSourcePath, err.Error())
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants