guibranco / projects-monitor

⚙️🔔 GitHub projects monitor
https://guilherme.straccini.com/projects-monitor/
MIT License
3 stars 0 forks source link

[FEATURE] Grab information from Snyk #17

Open guibranco opened 1 year ago

guibranco commented 1 year ago

Description:

We need to create an integration with the Snyk API to retrieve security vulnerability information for each of our repositories. This integration should query the repositories table to get the list of repositories, call the Snyk API, and store the results in a new dedicated table. The table will contain only key information from Snyk (e.g., vulnerability count, severity levels), without the full detailed data, to keep the data lightweight and easy to query.

Objectives:

  1. Create Snyk API Integration:

    • Develop a PHP integration class to interact with the Snyk API.
  2. Query the Repositories Table:

    • Retrieve the list of repositories from the existing repositories table.
  3. Call the Snyk API for Each Repository:

    • Use the new Snyk integration to fetch security vulnerability data for each repository.
  4. Create a New Database Table:

    • Design a new table to store only the relevant security information fetched from the Snyk API.
  5. Store Relevant Data:

    • Parse the Snyk API response and insert key data into the new table.

Tasks:

Code Example:

Here’s a pseudo-code example of how the integration might work:

// Fetch repositories from the database
$repositories = $database->query('SELECT id, name FROM repositories');

// Instantiate Snyk integration class
$snyk = new SnykIntegration('YOUR_API_KEY');

foreach ($repositories as $repository) {
    // Call Snyk API for each repository
    $snykData = $snyk->fetchRepositoryVulnerabilities($repository['name']);

    // Parse relevant fields from the Snyk API response
    $vulnerabilityCount = $snykData['vulnerabilities']['count'];
    $criticalIssues = $snykData['vulnerabilities']['critical'];
    $highIssues = $snykData['vulnerabilities']['high'];

    // Store relevant data in the new table
    $database->query('INSERT INTO snyk_info (repository_id, vulnerability_count, critical_issues, high_issues) 
                      VALUES (?, ?, ?, ?)', 
                      [$repository['id'], $vulnerabilityCount, $criticalIssues, $highIssues]);
}

Acceptance Criteria:

Additional Context:

By integrating with Snyk, we will be able to monitor security vulnerabilities across our repositories. This will help in identifying critical and high-severity issues in a lightweight manner and enable quick action based on the reported vulnerabilities.

gitauto-ai[bot] commented 1 month ago

Hey, I'm a bit lost here! Not sure which file I should be fixing. Could you give me a bit more to go on? Maybe add some details to the issue or drop a comment with some extra hints? Thanks!

Have feedback or need help? Feel free to email info@gitauto.ai.