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

feat: gerrit python plugin #6786

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

matrixji
Copy link
Member

@matrixji matrixji commented Jan 11, 2024

Summary

Provide a Python/plugin for support collecting data from Gerrit.

Does this close any open issues?

Closes #5871

Screenshots

image

Snip20240111_1

Snip20240111_2

Other Information

This is a WIP PR, currently, I use this code for collecting Gerrit changes/commits from the Gerrit server. If possible, I hope this could be merged into the master, I'm not sure if Python's plugin could provide full ability as the Golang's plugin does, Any comments are welcome.

@matrixji matrixji self-assigned this Jan 11, 2024
@matrixji matrixji marked this pull request as draft January 11, 2024 03:00
@matrixji
Copy link
Member Author

Looping @klesh @Startrekzky may also interested

@d4x1
Copy link
Contributor

d4x1 commented Jan 24, 2024

Does this support all gerrit versions?

request.headers["Authorization"] = f"Basic {basic_auth}"

@response_hook
def remove_extra_content_in_json(self, response: Response):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To prevent against Cross Site Script Inclusion (XSSI) attacks, the JSON response body starts with a magic prefix line that must be stripped before feeding the rest of the response body to a JSON parser:

Ref: https://gerrit-documentation.storage.googleapis.com/beta/rest-api.html#output-format

If the admin configure site.allowOriginRegex correctly, then the output should be OK for json parse directly, and this
remove_extra_content_in_json could always process the output w/o any pre configure on site.allowOriginRegex.

@matrixji
Copy link
Member Author

Does this support all gerrit versions?

Not sure, we're using v3.4.3 and I've done some UT in code with the https://gerrit.onap.org/r (V3.7.2)

@Startrekzky
Copy link
Contributor

Excellent stuff @matrixji . Since not many contributors know Python, it might take some take to review and merge the PR.

@klesh
Copy link
Contributor

klesh commented Jan 31, 2024

The PR is currently marked as DRAFT, is it ready for review?

@matrixji
Copy link
Member Author

The PR is currently marked as DRAFT, is it ready for review?

Apache-license-header is still not solved, I'll fix it recently and then marked as ready for review.

],
},
dataScope: {
localSearch: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this plugin have no API to support searching data scope?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Gerrit API should support searching, but sems python plugin framework not exporting this(not very sure) ...

ref:

return &plugin.ApiResourceOutput{Status: http.StatusNotImplemented}, nil

plugin: 'gerrit',
name: 'Gerrit',
icon: ({ color }) => <Icon fill={color} />,
sort: 7,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please double-check its sort.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've no idea which sort should be used, my understanding is: that this sort is just used for icon layout in UI.

@matrixji matrixji force-pushed the feat-gerrit branch 2 times, most recently from d952464 to 07b8387 Compare March 31, 2024 15:59
Signed-off-by: Ji Bin <matrixji@live.com>
Signed-off-by: Ji Bin <matrixji@live.com>
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.

[Feature][Gerrit] Create gerrit plugin
5 participants