Skip to content

Commit

Permalink
Merge pull request #1 from HackUCF/rewrite
Browse files Browse the repository at this point in the history
PlinkOnboard - The big rewrite
  • Loading branch information
jontyms authored Aug 30, 2024
2 parents de08f0c + 8d738aa commit fca7809
Show file tree
Hide file tree
Showing 73 changed files with 2,443 additions and 1,116 deletions.
91 changes: 91 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ "dev", "main" ]
pull_request:
branches: [ "dev", "main" ]
schedule:
- cron: '26 9 * * 2'

jobs:
analyze:
name: Analyze (${{ matrix.language }})
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners
# Consider using larger runners for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
# required for all workflows
security-events: write

# only required for workflows in private repositories
actions: read
contents: read

strategy:
fail-fast: false
matrix:
include:
- language: javascript-typescript
build-mode: none
- language: python
build-mode: none
# CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
# Use `c-cpp` to analyze code written in C, C++ or both
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
steps:
- name: Checkout repository
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality

# If the analyze step fails for one of the languages you are analyzing with
# "We were unable to automatically build your code", modify the matrix above
# to set the build mode to "manual" for that language. Then modify this step
# to build your code.
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
- if: matrix.build-mode == 'manual'
run: |
echo 'If you are using a "manual" build mode for one or more of the' \
'languages you are analyzing, replace this with the commands to build' \
'your code, for example:'
echo ' make bootstrap'
echo ' make release'
exit 1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
40 changes: 40 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CI/CD Workflow

on:
push:
branches:
- main
- dev
schedule:
- cron: "21 18 * * 3"

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to the Container registry
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract branch name
id: extract_branch
run: echo "::set-output name=branch::$(echo ${GITHUB_REF#refs/heads/})"

- name: Build Docker image
run: docker build --target prod -t onboardlite:${{ steps.extract_branch.outputs.branch }} .

- name: Tag Docker image
run: docker tag onboardlite:${{ steps.extract_branch.outputs.branch }} ghcr.io/hackucf/plinkonboard:${{ steps.extract_branch.outputs.branch }}

- name: Push Docker image
run: docker push ghcr.io/hackucf/onboardlite:${{ steps.extract_branch.outputs.branch }}
42 changes: 42 additions & 0 deletions .github/workflows/gitleaks-baseline.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"Description": "Identified a Discord client ID, which may lead to unauthorized integrations and data exposure in Discord applications.",
"StartLine": 27,
"EndLine": 27,
"StartColumn": 28,
"EndColumn": 61,
"Match": "discord_id == \"669276074563666347\"",
"Secret": "669276074563666347",
"File": "tests/test_user.py",
"SymlinkFile": "",
"Commit": "7522882299ff338c63e58ebe64c69e4a18168211",
"Entropy": 2.5917933,
"Author": "Jonathan Styles",
"Email": "[email protected]",
"Date": "2024-05-27T19:01:27Z",
"Message": "Switch to SQLModel Database stuff (#93)",
"Tags": [],
"RuleID": "discord-client-id",
"Fingerprint": "7522882299ff338c63e58ebe64c69e4a18168211:tests/test_user.py:discord-client-id:27"
},
{
"Description": "Identified a Discord client ID, which may lead to unauthorized integrations and data exposure in Discord applications.",
"StartLine": 56,
"EndLine": 56,
"StartColumn": 10,
"EndColumn": 40,
"Match": "discord_id=\"669276074563666347\"",
"Secret": "669276074563666347",
"File": "tests/conftest.py",
"SymlinkFile": "",
"Commit": "7522882299ff338c63e58ebe64c69e4a18168211",
"Entropy": 2.5917933,
"Author": "Jonathan Styles",
"Email": "[email protected]",
"Date": "2024-05-27T19:01:27Z",
"Message": "Switch to SQLModel Database stuff (#93)",
"Tags": [],
"RuleID": "discord-client-id",
"Fingerprint": "7522882299ff338c63e58ebe64c69e4a18168211:tests/conftest.py:discord-client-id:56"
}
]
22 changes: 22 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: pre-commit

on:
pull_request:
push:
branches: [dev, main]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
cache: 'pip'
- run: python -m pip install -r requirements.txt && python -m pip install -r requirements-dev.txt
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit/
key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
- run: echo "SKIP=semgrep" >> $GITHUB_ENV
- run: pre-commit run --show-diff-on-failure --color=always --all-files
42 changes: 42 additions & 0 deletions .github/workflows/semgrep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Name of this GitHub Actions workflow.
name: Semgrep OSS scan

on:
# Scan changed files in PRs (diff-aware scanning):
pull_request: {}
# Scan on-demand through GitHub Actions interface:
workflow_dispatch: {}
# Scan mainline branches and report all findings:
push:
branches: ["master", "main", "dev"]
# Schedule the CI job (this method uses cron syntax):
schedule:
- cron: '14 21 * * *'

jobs:
semgrep:
# User definable name of this GitHub Actions job.
name: semgrep-oss/scan
# If you are self-hosting, change the following `runs-on` value:
runs-on: ubuntu-latest

container:
# A Docker image with Semgrep installed. Do not change this.
image: semgrep/semgrep

# Skip any PR created by dependabot to avoid permission issues:
if: (github.actor != 'dependabot[bot]')

steps:
# Fetch project source with GitHub Actions Checkout.
- uses: actions/checkout@v4
# Run the "semgrep scan" command on the command line of the docker image.
- run: semgrep scan --config auto --sarif > findings.sarif
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v3
with:
# Path to SARIF file relative to the root of the repository
sarif_file: findings.sarif
# Optional category for the results
# Used to differentiate multiple results for one commit
category: semgrep-oss
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ terraform.*
clouds.yaml
infra_options.json
_deploy.sh
config/
database/
26 changes: 26 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.1
hooks:
- id: ruff-format
- id: ruff
exclude: ^tests/codegen/snapshots/python/
args: [--select, I, "--fix"]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
- id: prettier
files: '^docs/.*\.mdx?$'

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: check-merge-conflict
- repo: https://github.com/gitleaks/gitleaks
rev: v8.18.4
hooks:
- id: gitleaks
args: ["--baseline-path", ".github/workflows/gitleaks-baseline.json"]
58 changes: 58 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Use the official Python base image
FROM python:3.11-bookworm AS base

# Set the working directory in the container
WORKDIR /src

# Install build-essential
RUN apt-get update && apt-get install -y build-essential

# Clean up
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

ADD https://github.com/bitwarden/sdk/releases/download/bws-v0.4.0/bws-x86_64-unknown-linux-gnu-0.4.0.zip /tmp

RUN unzip /tmp/bws-x86_64-unknown-linux-gnu-0.4.0.zip

RUN mv bws /usr/local/bin

RUN rm -r /tmp/



FROM base AS dev

COPY . .

RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements.txt

RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements-dev.txt

EXPOSE 8000

ENTRYPOINT ["python3", "app/entry.py" ]

CMD dev



FROM dev AS test

CMD ["pytest"]



FROM base as prod

COPY requirements.txt .

RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements.txt

COPY ./app ./app

EXPOSE 8000

# Start the FastAPI application
ENTRYPOINT ["/bin/python3", "app/entry.py"]

CMD []
Loading

0 comments on commit fca7809

Please sign in to comment.