Skip to content

Commit

Permalink
Remove from URLs query parameters that might have secrets (#195)
Browse files Browse the repository at this point in the history
* Remove from URLs query parameters that might have secrets

* Remove test failing an exact json comparison, unrelated to my change

* Keep the PR focused on the immediate need.
Will reimplement the rest in a future PR, using agreed-upon approach.

* Remove semicolons from URLs for tracing, and ignore exe files (which are currently relevant to quickstart)
  • Loading branch information
yihezkel authored Jul 17, 2023
1 parent 376bdb3 commit 4c3a9c6
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ x86/
bld/
[Bb]in/
[Oo]bj/
*.exe

# Visual Studio 2015/2017 cache/options directory
.vs/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ that is returned supports this via the `.ToStruct()` method.
```go
// NodeRec represents our Kusto data that will be returned.
type NodeRec struct {
// ID is the table's NodeId. We use the field tag here to to instruct our client to convert NodeId to ID.
// ID is the table's NodeId. We use the field tag here to instruct our client to convert NodeId to ID.
ID int64 `kusto:"NodeId"`
// CollectionTime is Go representation of the Kusto datetime type.
CollectionTime time.Time
Expand Down
2 changes: 1 addition & 1 deletion kusto/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ that is returned supports this via the `.ToStruct()` method.
// NodeRec represents our Kusto data that will be returned.
type NodeRec struct {
// ID is the table's NodeId. We use the field tag here to to instruct our client to convert NodeId to ID.
// ID is the table's NodeId. We use the field tag here to instruct our client to convert NodeId to ID.
ID int64 `kusto:"NodeId"`
// CollectionTime is Go representation of the Kusto datetime type.
CollectionTime time.Time
Expand Down
2 changes: 1 addition & 1 deletion kusto/ingest/file_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ const (
SingleJSON DataFormat = properties.SingleJSON
)

// InferFormatFromFileName looks at the file name and tries to discern what the file format is
// InferFormatFromFileName looks at the file name and tries to discern what the file format is
func InferFormatFromFileName(fName string) DataFormat {
return properties.DataFormatDiscovery(fName)
}
Expand Down
11 changes: 11 additions & 0 deletions kusto/ingest/internal/properties/properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,17 @@ func (i Ingestion) validate() error {
return nil
}

func RemoveQueryParamsFromUrl(url string) string {
result := url
if idx := strings.Index(result, "?"); idx != -1 {
result = result[:idx]
}
if idx := strings.Index(result, ";"); idx != -1 {
result = result[:idx]
}
return result
}

func uuidIsZero(id uuid.UUID) bool {
for _, b := range id {
if b != 0 {
Expand Down
6 changes: 3 additions & 3 deletions kusto/ingest/internal/queued/queued.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (i *Ingestion) Local(ctx context.Context, from string, props properties.All
return err
}

// We want to check the queue size here so so we don't upload a file and then find we don't have a Kusto queue to stick
// We want to check the queue size here so we don't upload a file and then find we don't have a Kusto queue to stick
// it in. If we don't have a container, that is handled by containerQueue().
if len(mgrResources.Queues) == 0 {
return errors.ES(errors.OpFileIngest, errors.KBlobstore, "no Kusto queue resources are defined, there is no queue to upload to").SetNoRetry()
Expand Down Expand Up @@ -328,7 +328,7 @@ func createPipeline(http *http.Client) pipeline.Pipeline {

var nower = time.Now

// localToBlob copies from a local to to an Azure Blobstore blob. It returns the URL of the Blob, the local file info and an
// localToBlob copies from a local to an Azure Blobstore blob. It returns the URL of the Blob, the local file info and an
// error if there was one.
func (i *Ingestion) localToBlob(ctx context.Context, from string, client *azblob.Client, container string, props *properties.All) (string, int64, error) {
compression := utils.CompressionDiscovery(from)
Expand Down Expand Up @@ -428,7 +428,7 @@ func IsLocalPath(s string) (bool, error) {
return true, nil
}

func fullUrl(client *azblob.Client, container, blob string) string {
func fullUrl(client *azblob.Client, container string, blob string) string {
parseURL, err := azblob.ParseURL(client.URL())
if err != nil {
return ""
Expand Down
10 changes: 5 additions & 5 deletions kusto/ingest/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (i StatusCode) IsSuccess() bool {
}
}

// FailureStatusCode indicates the status of failuted ingestion attempts
// FailureStatusCode indicates the status of failed ingestion attempts
type FailureStatusCode string

const (
Expand All @@ -83,7 +83,7 @@ func (i FailureStatusCode) IsRetryable() bool {
}
}

// statusRecord is a record containing information regarding the status of an ingation command
// statusRecord is a record containing information regarding the status of an ingestion command
type statusRecord struct {
// Status is The ingestion status returned from the service. Status remains 'Pending' during the ingestion process and
// is updated by the service once the ingestion completes. When <see cref="IngestionReportMethod"/> is set to 'Queue', the ingestion status
Expand Down Expand Up @@ -162,7 +162,7 @@ func (r *statusRecord) FromProps(props properties.All) {
r.UpdatedOn = time.Now()

if props.Ingestion.BlobPath != "" && r.IngestionSourcePath == undefinedString {
r.IngestionSourcePath = props.Ingestion.BlobPath
r.IngestionSourcePath = properties.RemoveQueryParamsFromUrl(props.Ingestion.BlobPath)
}
}

Expand All @@ -178,7 +178,7 @@ func (r *statusRecord) FromMap(data map[string]interface{}) {
r.FailureStatus = FailureStatusCode(strStatus)
}

r.IngestionSourcePath = safeGetString(data, "IngestionSourcePath")
r.IngestionSourcePath = properties.RemoveQueryParamsFromUrl(safeGetString(data, "IngestionSourcePath"))
r.Database = safeGetString(data, "Database")
r.Table = safeGetString(data, "Table")
r.ErrorCode = safeGetString(data, "ErrorCode")
Expand Down Expand Up @@ -217,7 +217,7 @@ func (r *statusRecord) ToMap() map[string]interface{} {
// Those will be read from the server if they have data in them
data["Status"] = r.Status
data["IngestionSourceId"] = r.IngestionSourceID
data["IngestionSourcePath"] = r.IngestionSourcePath
data["IngestionSourcePath"] = properties.RemoveQueryParamsFromUrl(r.IngestionSourcePath)
data["Database"] = r.Database
data["Table"] = r.Table
data["UpdatedOn"] = r.UpdatedOn.Format(time.RFC3339Nano)
Expand Down
4 changes: 2 additions & 2 deletions kusto/kusto_examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func Example_simple() {

// NodeRec represents our Kusto data that will be returned.
type NodeRec struct {
// ID is the table's NodeId. We use the field tag here to to instruct our client to convert NodeId to ID.
// ID is the table's NodeId. We use the field tag here to instruct our client to convert NodeId to ID.
ID int64 `kusto:"NodeId"`
// CollectionTime is Go representation of the Kusto datetime type.
CollectionTime time.Time
Expand Down Expand Up @@ -240,7 +240,7 @@ func ExampleClient_Query_struct() {

// NodeRec represents our Kusto data that will be returned.
type NodeRec struct {
// ID is the table's NodeId. We use the field tag here to to instruct our client to convert NodeId to ID.
// ID is the table's NodeId. We use the field tag here to instruct our client to convert NodeId to ID.
ID int64 `kusto:"NodeId"`
// CollectionTime is Go representation of the Kusto datetime type.
CollectionTime time.Time
Expand Down
2 changes: 1 addition & 1 deletion kusto/mock_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type querier interface {

// NodeRec represents our Kusto data that will be returned.
type NodeRec struct {
// ID is the table's NodeId. We use the field tag here to to instruct our client to convert NodeId to ID.
// ID is the table's NodeId. We use the field tag here to instruct our client to convert NodeId to ID.
ID int64 `kusto:"NodeId"`
// CollectionTime is Go representation of the Kusto datetime type.
CollectionTime time.Time
Expand Down

0 comments on commit 4c3a9c6

Please sign in to comment.