Syslifters / offsec-tools

Compiled tools for internal assessments
https://syslifters.com/
253 stars 40 forks source link

CICD configuration #3

Closed Kahyo-dev closed 1 year ago

Kahyo-dev commented 1 year ago

Hello,

I'm using your awesome work and documentation to setup our own cicd and I was wondering if you had encountered the same error i'm facing. When my job starts :
Getting source from Git repository Fetching changes with git depth set to 20... Initialized empty Git repository in C:/gitlab-runner/builds/1z4ion-u/0/xxx/tools/yyy/.git/ Created fresh repository. remote: HTTP Basic: Access denied. The provided password or token is incorrect or your account has 2FA enabled and you must use a personal access token instead of a password. See http://aaa.bbb.cc/help/topics/git/troubleshooting_git#error-on-git-fetch-http-basic-access-denied fatal: Authentication failed for 'http://aaa.bbb.cc/xxx/tools/yyy.git/'

The repository is private, I included the before script commands in my pipeline and set up the variables (from your doc).

I was wondering if maybe there is a configuration for the gitlab-runner on Windows that may be missing in your documentation ?

cmahrl commented 1 year ago

Hi, Thanks for the feedback! Did you follow the steps from the HOWTO (https://github.com/Syslifters/offsec-tools/blob/main/HOWTO.md)? It appears that you specified your password as token and didn't create a personal access token (see step 2).

Also note, that the current gitlab-ci.yml is designed to push to another "remote" repository, either GitHub or GitLab, and not to the same repo where the gitlab-ci.yml resides. So you have to create a personal access token for the "remote" repository on GitHub / GitLab (can be private ofc).

Kahyo-dev commented 1 year ago

Thanks for the quick answer ! Yes i did follow the steps from the HOWTO. Even though i'm not trying to push to another repo i still configured my personal access token and all the variables from the documentation. But the pipeline fails at the very first step as soon as the job tries to fetch the project where the gitlab-ci.yml is.

cmahrl commented 1 year ago

Ok, as mentioned the gitlab-ci is not designed to push to the same repo. So first try to create and push to another repository and see if it works then. If this is not working, I'd try to manually replicate the steps in the gitlab-ci on the gitlab-runner and see if this works. E.g. on your gitlab-runner can you manually clone/fetch the repo using the token?

Kahyo-dev commented 1 year ago

Thanks for your help I managed to find the solution. It seems to be a "bug". Thanks to this thread I found the solution (which is adding a clone_url entry with the same value as url in the runner configuration file). Seems a bit like a hack but it's working for now ! Thx again !