Create an issue WITH labels via GitHub API, - github-api

I am trying to add an issue to a GitHub repository via the GitHub API. I use OAuth with a scope of user,repo,gist. The issue gets created just fine, but the labels are silently dropped.
I read on the GitHub website:
"Only users with push access can set labels for new issues. Labels are
silently dropped otherwise."
So my question is this: What is push access? Do I need to add something to my scope to allow a user to do this?

I assume you need to be authenticated as a user that is allowed to push (as in git push) to the repository. That means, either the repository owner or a collaborator ("Settings" >> "Collaborators").

I just stumbled across this while looking for a simple URL-way to add labels to issues.
Turns out there is something: it's labels=!
So on a new issue where it's the first param that'd be:
https://github.com/github/issue-labeler/issues/new?labels=bug,enhancement
Otherwise &labels=...
This also works if you don't have any push access!
Of course nonexistent labels are also silently dropped and this does not yet submit the issue. I'm sorry if it does not apply.

Related

Gitlab Issues Webhook Information

So, i have a public project that allows other people in my organization to open issues. I would like labels applied to each issue when it is opened. I have tried the /label method and that only works when the person opens the issue is a part of the project. It seems that Gitlab does not allow this as per this issue: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/73710
So, to get around this, I have set up a webhook that triggers a pipeline, parses some text at the end of the issue description (like ISS001)and then uses the Issues API to set the labels.
I have two questions that I can't seem to find a concrete answer to.
In the Webhook payload, does any of that information tell you what template was used? Looking through the payload, I cannot see any indication of that... which is why I am parsing the text at the bottom. In the object_attributes portion of the payload I see:
"id": <What is this?>,
"iid": <Issue Id>,
iid is the issue id, but what is id? I can't find that anywhere.
Is there a way to configure the cicd pipeline to only trigger on issue CREATE.. not update, close, reopen? I have it set as:
only:
- trigger
So no other actions trigger the pipeline but there are a TON of superfluous pipeline runs.
Thank you.

securing a Google Apps Script linked to an authorized trigger so others can edit

I am pretty sure my understanding is correct but since I cannot find any Google documentation that explicitly highlights this I wanted to ask here.
Per https://developers.google.com/apps-script/guides/triggers/installable:
Installable triggers always run under the account of the person who created them.
And we know that when you create a trigger it will ask to authorize for all the scopes the script uses.
Then, that means that anyone with edit access to the script could leverage the Google identity of the user used to create the trigger to access the scopes the trigger is authorized for.
For example:
User 1 creates a Google Apps Script that uses GmailApp to send an e-mail
(i.e. GmailApp.sendEmail("one#example.com", "test subject", "email body");)
User 1 creates a trigger to run said script every hour and authorizes it with the appropriate GmailApp scopes
User 1 gives User 2 edit access to said script
Now, User 2 can go into said script and make changes to the code and access User 1's Gmail account. For example, user 2 could change the code to:
var emails = GmailApp.search("search string to find sensitive emails")
// use GmailApp.sendEmail to forward those details to someone else like User 2
All they would have to do is make changes to the code and save; they wouldn't need to re-create the trigger since it already exists. And the next time the trigger runs it would run the newer/updated code.
I was able to confirm this behavior by creating a test script on one of my accounts and giving another account edit access.
So my question is, what is the official/recommended way to mitigate this risk? The obvious answer is to not give anyone else edit access but what if that is not an option -- what if for support purposes multiple people need to be able to access the script, then what?
As you say, the only official/recommend way is to limit editing access to trusted persons.
In your particular example, User 1 could have chosen MailApp instead of GmailApp. The two seemingly redundant services are available separately because MailApp has very limited privledges exposed compared to GmailApp. (For instance, User 2 cannot search the victims Gmail with the MailApp service.)
You can collaborate while avoiding giving direct access to your script file using clasp and git. Only you push with clasp to the script. Everyone else submits changes through git. You can setup the system to be fully automatic (i.e. a git push triggers a clasp push) or manual (i.e. you review all changes first), bit either way you have good records of who did what, when with git.
There's inherent trust when you provide edit access to the script project. You either trust the person or don't trust them. There's no inbetween.
Some "theoretical" ways you may still protect the data:
Create and use different Google accounts.
Install Triggers at the specific deployment/not at Head:
Possible only if done manually. Installable triggers created programmatically can only be used at Head
When you deploy a web-app/api, You can deploy it a specific version.
This deployment version can then be provided, When you create a new trigger for a project here.
There is no need for a working web-app/api. We're only looking to get a deployment id.
In this way, even if user changes the script, your trigger will only run at the old version deployed.
Deployed versions can be seen at Publish> Deploy from manifest.
As the previous answer states, git would be a better call.
For all practical purposes, any data you share with a malicious entity should be considered compromised.

Can you get commit information of a pullrequest using the pullrequest ID (without knowing the issue number)?

I have the pull request id of all the pull requests in a public repository. I was wondering if I could use this information to get the commit level information using Github api? I understand that this is fairly simple if the issue number is known. Unfortunately, i do not have the issue number for the pull requests.
The best you can do is to search all issues based on repo name,type (:pr) and date of creation. Using the api, the above search would translate into - https://api.github.com/search/issues?q=repo:km-Poonacha/testissues+type:pr+created:2017-06-16. I think one of the problems of using the id is that each pullrequest has an issue id and a different pullrequest id.
GitHub does not have any endpoints that allow you to filter using PullRequestevent ID. So, I guess the method you used by filtering based on type and date of creation is the best you can do for now.

API issue when editing order in opencart admin

Afternoon all,
I've got an issue when trying to change the status of an order (from pending to complete etc...) in the admin section.
A warning appears saying
Warning: You do not have permission to access the API!
if i have add my IP to the API IP address section it's working fine
the fields are all in red and the continue button doesn't work.
A similar thing happens if I view an order instead and try to add a new status to the order history.
I've seen this problem mentioned a few times in other posts but, afaik, without any satisfactory answer.
I'm using Opencart 2.0.3.1 and I'm logged in as an administrator and the administrator user group has all Access and Modify permissions enabled.
There is the default API user set up in System > Users > API and I also added (and then removed) another one but I was not sure what to do once I had created a new API user with a username and generated password.
There are no other problems on the site but, despite trying just about all the suggestions in the other forum posts, I can't edit the existing orders from the admin section.
Check this page out with a list of fixes for this issue: http://www.randemsystems.com/support/opencart/api-problems-what-you-need-to-know/msg6218/#msg6218
As far as I know, this issue is resolved in OC v2.1x onwards
The problem is that you need an API user with a valid IP address.
Go to System > Users > API.
Either modify the Default API by adding your IP address in the second tab, or just create a new API.
After that you should make sure the API is selected in System > Settings > Edit > Option > API User.
Click save, refresh and try adding order history again.
I tried the same thing and didn’t have permission to access the API when attempting to add order history. Follow the steps and it should work for you, as it worked for me.
I know it's late, but after trying everything and not getting it working, I deleted everything here /system/storage/cache. It solved the problem.
It works perfect for me .
1- Open index.php file of root directory
2- add the following after define('version',x.x.x.x);
if ($_SERVER["HTTP_CF_CONNECTING_IP"])
{
$_SERVER["REMOTE_ADDR"] = $_SERVER["HTTP_CF_CONNECTING_IP"];
}

Get gitlab-ci token with gitlab API

This question's answers are a community effort. Edit existing answers to improve this post. It is not currently accepting new answers or interactions.
It's unclear from the API how to get the token that can be used to clone http repositories.
From the documentation here:
http://doc.gitlab.com/ee/ci/api/README.html
It should be possible to GET this url:
http://gitlab.com/ci/api/v1/projects?private_token=QVy1PB7sTxfy4pqfZM1U&url=http://demo.gitlab.com/
I'm not sure where the url parameter is taken from but even with just my private token, it receive a 404 error page.
I tried with the ci subdomain but it simply redirect me to gitlab.com.
That said, I'll explain a bit more the reason why I need that. I have a server that could have multiple projects. Each projects will contain a list of repositories private/public each project has to be cloned/pulled and whatever regularly. Unlike github, gitlab doesn't provide a oauth2 token that is sitewide and instead provide a CI-token for each project. I could make sure that the user enter the token for each project but that is way more complicated than entering the private token.
On the other hand, I could generate SSH keys for each users and add the public key to their account and this way it would be possible to fetch/clone with ssh instead of http. But that is a bit more work on my end than just fetching a token and cloning with a basic auth url
git clone https://gitlab-ci-token:token#gitlab.com/project.git
You can find the token by doing the following from gitlab.com
Click on the project you are working on from the starting screen
Click "Settings" on the left hand navigation
Scroll down to the bottom and click "CI / CD" which is nested in Settings
Under the "Runners" section click expand
Token is hidden here.
Took me 10 minutes to find this... not documented anywhere.
According to new Gitlab CI Build Permissions Model, HTTPS is now a requirement to clone all the sources. So that rules out the SSH option.
Now to clone any private repo you can just do:
git clone https://gitlab-ci-token:${CI_JOB_TOKEN}#gitlab.com/<group_name>/<repo>.git
Also, you DONT need to specify the value for CI_JOB_TOKEN. It is taken automatically. So, just fill in the <group_name> and <repo>.
Also, remember that gitlab.com can be replaced by gitlab.xyz.cloud (your private gitlab enterprise) and this will still work.
Needless to say that you would never actually require the value of CI_JOB_TOKEN
The url to retrieve your token is located under the following path /profile/account.
Or you can just navigate to Profile Settings -> Account
Also make sure you are using the right version of the api. At the time of this response is currently on v3 /api/v3/projects?private_token={my_private_token}
gitlab-ci-token can be found at [Go to left side panel -> settings -> ci/cd->runners]
I would say to check the type of token you want.
Private token?
Navigate to Profile Settings -> account.
A token can be generated if you want to trigger a new CI/CD pipeline and this can be done by navigating to Project Settings-> CI/CD pipelines -> Create a token
Also, It is important that you have the right privileges to Git.

Resources