-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Update postman metadata #3852
Update postman metadata #3852
Conversation
…updated the metadata fields
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool stuff! i left comment reminders of what we discussed synchronously. let's also wait for joe to sign-off on the request body stuff.
pkg/output/plain.go
Outdated
if reflect.TypeOf(obj) == reflect.TypeOf(&source_metadatapb.MetaData_Postman{}) { | ||
m["Postman"]["location"] = obj.(*source_metadatapb.MetaData_Postman).Postman.Location.String() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably no need to reflect; just check the generated dictionary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also pls add an explanatory (apologetic) comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
pkg/sources/postman/postman.go
Outdated
metadata.Location = source_metadatapb.PostmanLocation_UNKNOWN_POSTMAN | ||
ctx.Logger().V(2).Info("finished scanning environment vars", "environment_uuid", metadata.FullID) | ||
metadata.Type = "" | ||
metadata.Link = "" | ||
metadata.FullID = "" | ||
metadata.EnvironmentID = "" | ||
metadata.EnvironmentName = "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log before or after, but not in the middle!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
proto/source_metadata.proto
Outdated
string request_name = 9; | ||
string folder_id = 10; | ||
string folder_name = 11; | ||
string field_type = 12; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leave a comment saying that this field is used for local output but not in transport
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
proto/source_metadata.proto
Outdated
PostmanLocation location = 13; | ||
} | ||
|
||
enum PostmanLocation { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to PostmanLocationType
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
proto/source_metadata.proto
Outdated
string folder_id = 10; | ||
string folder_name = 11; | ||
string field_type = 12; | ||
PostmanLocation location = 13; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to location_type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
string field_name = 14; | ||
string variable_type = 15; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reserve these numbers (https://protobuf.dev/best-practices/dos-donts/#reserve-tag-numbers)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done and for globals_id
as well. I also reserved the names too.
} | ||
// We would scan the body, but currently the body has different radio buttons that can be scanned but only the selected one is scanned. The unselected radio button options can still | ||
// have secrets in them but will not be scanned. The selction of the radio button will also change the secret metadata for that particular scanning pass and can create confusion for | ||
// the user as to the status of a secret. We will reimplement at some point. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little unclear - does the API prevent us from scanning the body data from the unselected fields?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Postman API will need further exploration to answer that question Joe. As it is written in main
currently, I'm not seeing unselected fields getting scanned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood. I think it's still worth it to scan the body data that we can see, but if that confuses the user, then I understand punting it down the road. I'll just add that if the Postman API doesn't allow us to scan all body types now, it likely never will, so the existing implementation might be the only option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great work man!
@@ -110,6 +110,16 @@ func structToMap(obj any) (m map[string]map[string]any, err error) { | |||
return | |||
} | |||
err = json.Unmarshal(data, &m) | |||
// Due to PostmanLocationType protobuf field being an enum, we want to be able to assign the string value of the enum to the field without needing to create another Protobuf field. | |||
// To have the "UNKNOWN_POSTMAN = 0" value be assigned correctly to the field, we need to check if the Postman workspace ID is filled since every secret in the Postman source | |||
// should have a valid workspace ID and the 0 value is considered nil for integers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love this comment - it explains the problem as well as why you picked the solution you did.
Description:
global_id
,field_name
, andvariable_type
.Checklist:
make test-community
)?make lint
this requires golangci-lint)?