Skip to content

Stuart/unify contributor scripts#125

Open
stuartcmehrens wants to merge 4 commits intomainfrom
stuart/unifyContributorScripts
Open

Stuart/unify contributor scripts#125
stuartcmehrens wants to merge 4 commits intomainfrom
stuart/unifyContributorScripts

Conversation

@stuartcmehrens
Copy link
Contributor

We have a lot of contributor scripts floating around. This PR merges them all into a CLI utility that should be easier to maintain and improve upon moving forward.

@stuartcmehrens stuartcmehrens marked this pull request as ready for review June 27, 2025 20:23
@sebasrevuelta sebasrevuelta self-requested a review September 2, 2025 13:39
Copy link
Collaborator

@sebasrevuelta sebasrevuelta left a comment

Choose a reason for hiding this comment

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

Tested GitHub contributors. It works fine. I added a couple of comments that I think should be applied to the other SCMs. Good job @stuartcmehrens

#### GitHub

```bash
semgrep-contributors github [OPTIONS]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
semgrep-contributors github [OPTIONS]
semgrep-contributors get-contributors github [OPTIONS]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching this -- I found a few more instances and updated accordingly!

- `--api-key TEXT`: GitHub API key (or set `GITHUB_API_KEY` environment variable)
- `--org-name TEXT`: Name of the GitHub organization (required)
- `--number-of-days INTEGER`: Number of days to analyze (default: 30)
- `--output-filename TEXT`: Output JSON file path (optional)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- `--output-filename TEXT`: Output JSON file path (optional)
- `--output-dir TEXT`: Output path (optional)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching this -- I found a few more instances and updated accordingly!

@semgrep-code2-r2c-cse
Copy link

Legal Risk

The following dependencies were released under a license that
has been flagged by your organization for consideration.

Recommendation

While merging is not directly blocked, it's best to pause and consider what it means to use this license before continuing. If you are unsure, reach out to your security team or Semgrep admin to address this issue.

Apache-2.0

MIT

1 similar comment
@semgrep-code2-r2c-cse
Copy link

Legal Risk

The following dependencies were released under a license that
has been flagged by your organization for consideration.

Recommendation

While merging is not directly blocked, it's best to pause and consider what it means to use this license before continuing. If you are unsure, reach out to your security team or Semgrep admin to address this issue.

Apache-2.0

MIT


ENV PATH="/app/.venv/bin:$PATH"

ENTRYPOINT ["semgrep-contributors"]

Choose a reason for hiding this comment

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

Semgrep identified an issue in your code:
By not specifying a USER, a program in the container may run as 'root'. This is a security hazard. If an attacker can control a process running as root, they may have control over the container. Ensure that the last USER in a Dockerfile is a USER other than 'root'.

To resolve this comment:

✨ Commit Assistant fix suggestion

Suggested change
ENTRYPOINT ["semgrep-contributors"]
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
WORKDIR /app
ENV UV_COMPILE_BYTECODE=1
ENV UV_LINK_MODE=copy
COPY pyproject.toml uv.lock /app/
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --locked --no-install-project --no-dev
COPY . /app
RUN --mount=type=cache,target=/root/.cache/uv \
uv pip install . --no-deps
ENV PATH="/app/.venv/bin:$PATH"
# Create non-root user 'appuser' with UID 1000
RUN useradd -m -u 1000 appuser && \
chown -R appuser /app
# Switch to non-root user
USER appuser
ENTRYPOINT ["semgrep-contributors"]
View step-by-step instructions
  1. Add a non-root user to your Dockerfile after installing your dependencies but before setting the ENTRYPOINT.
    For example, add RUN useradd -m -u 1000 appuser to create a new user named appuser.
  2. Change the active user by adding USER appuser before the ENTRYPOINT line.
    For example:
    RUN useradd -m -u 1000 appuser
    USER appuser
    ENTRYPOINT ["semgrep-contributors"]
    
  3. Make sure any files or directories your app needs write access to are owned or writable by appuser.
    You can use a command like RUN chown -R appuser /app if needed.
💬 Ignore this finding

Reply with Semgrep commands to ignore this finding.

  • /fp <comment> for false positive
  • /ar <comment> for acceptable risk
  • /other <comment> for all other reasons

Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by missing-user-entrypoint.

You can view more details about this finding in the Semgrep AppSec Platform.

@semgrep-code2-r2c-cse
Copy link

Legal Risk

The following dependencies were released under a license that
has been flagged by your organization for consideration.

Recommendation

While merging is not directly blocked, it's best to pause and consider what it means to use this license before continuing. If you are unsure, reach out to your security team or Semgrep admin to address this issue.

Apache-2.0

MIT

1 similar comment
@semgrep-code2-r2c-cse
Copy link

Legal Risk

The following dependencies were released under a license that
has been flagged by your organization for consideration.

Recommendation

While merging is not directly blocked, it's best to pause and consider what it means to use this license before continuing. If you are unsure, reach out to your security team or Semgrep admin to address this issue.

Apache-2.0

MIT

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.

2 participants