Automatisieren von Abhängigkeitsupdates
Beispielszenario
Angenommen, dein Projekt hängt von zahlreichen Bibliotheken und Paketen ab. Anfällige oder veraltete Abhängigkeiten erzeugen Sicherheitsrisiken, die sich auf dein Projekt und andere auswirken können, die darauf angewiesen sind.
Copilot-Chat kann Ihnen dabei helfen, Sicherheits Dependabot - und Versionsupdates einzurichten, sodass Ihre Abhängigkeiten immer auf den sichersten und up-to-date-Versionen verbleiben. Siehe Informationen zu Dependabot-Sicherheitsupdates und Informationen zu Updates von Dependabot-Versionen.
Bevor Sie beginnen, stellen Sie sicher, dass Dependabot in den „Einstellungen“ Ihres Repositorys vollständig aktiviert ist.
- Stellen Sie in Ihren „Code security“-Einstellungen sicher, dass Dependabot alerts und Dependabot security updates beide auf „Aktiviert“ gesetzt sind.
- Erstellen Sie eine leere
.github/dependabot.yml-Datei und fügen Sie sie dem Repository hinzu.
Beispielaufforderung
Stelle sicher, dass dein Repository mit dem Prompt für den Kontext verbunden ist.
Analyze the codebase and project structure of this repository. Detect all package managers and package ecosystems in use, including their respective locations (e.g., npm, yarn, pip, maven, gradle, composer, github-actions, etc.). For each detected ecosystem, create a configuration entry in a single, top-level .github/dependabot.yml file that enables security and version updates on a reasonable schedule. Use the recommended best practices for each ecosystem. Clearly specify the directory for each ecosystem detected. If multiple ecosystems or multiple directories are present, include them all in the configuration. In the output, include any notes on the configuration or best practices, as well as next steps that include how to commit the dependabot.yml file to the repository via the GitHub web browser and how to check that Dependabot version updates and Dependabot security updates are enabled.
Analyze the codebase and project structure of this repository. Detect all package managers and package ecosystems in use, including their respective locations (e.g., npm, yarn, pip, maven, gradle, composer, github-actions, etc.).
For each detected ecosystem, create a configuration entry in a single, top-level .github/dependabot.yml file that enables security and version updates on a reasonable schedule. Use the recommended best practices for each ecosystem. Clearly specify the directory for each ecosystem detected. If multiple ecosystems or multiple directories are present, include them all in the configuration.
In the output, include any notes on the configuration or best practices, as well as next steps that include how to commit the dependabot.yml file to the repository via the GitHub web browser and how to check that Dependabot version updates and Dependabot security updates are enabled.
Beispielausgabe
Copilot-Chat analysiert Ihr Repository und schreibt für Sie den Inhalt der Konfigurationsdatei dependabot.yml, die Dependabot mitteilt, welche Abhängigkeiten gescannt werden sollen.
version: 2
updates:
# Python (pip)
- package-ecosystem: "pip"
directory: "/" # Location of requirements.txt
schedule:
interval: "weekly" # Weekly updates are a good balance for libraries
day: "sunday"
time: "06:00"
timezone: "UTC"
open-pull-requests-limit: 5
allow:
- dependency-type: "all"
commit-message:
prefix: "pip"
labels:
- "dependencies"
- "python"
ignore:
- dependency-name: "pip" # Ignore pip self-updates
# GitHub Actions
- package-ecosystem: "github-actions"
directory: "/" # Looks for workflow files under .github/workflows/
schedule:
interval: "weekly"
day: "sunday"
time: "06:00"
timezone: "UTC"
open-pull-requests-limit: 5
commit-message:
prefix: "actions"
labels:
- "dependencies"
- "github-actions"
Nachdem Sie die dependabot.yml-Datei in Ihr Repository committet haben, beginnt Dependabot, Pull Requests für Ihr Repository zu öffnen, sobald eine verwundbare oder veraltete Abhängigkeit erkannt wird.
Anpassen der Abhängigkeitsverwaltung
Beispielszenario
Angenommen, Ihr Team hat die grundlegende Dependabot Konfiguration für einige Monate verwendet, und Sie erhalten viele Pullanforderungen für Abhängigkeitsupdates. Du stellst jedoch Folgendes fest:
- Pull-Requests bleiben ungeprüft, da niemand automatisch zugewiesen wird.
- Du möchtest, dass Pull Requests automatisch über ein Label dem Projektboard deines Teams hinzugefügt werden.
- Dein Continuous Integration-System ist mit zu vielen gleichzeitigen Pull-Requests für Abhängigkeiten überfordert.
- Du erhältst Updates für Entwicklungsabhängigkeiten, die sich nicht auf die Produktion auswirken.
Sie möchten Ihre Dependabot Konfiguration an den Workflow Ihres Teams anpassen, z. B. das automatische Zuweisen von Pullanforderungen zu den richtigen Teammitgliedern, das Hinzufügen von Bezeichnungen zum Hinzufügen von Pullanforderungen zum Project Board, das Einschränken der Anzahl offener Pullanforderungen und die Konzentration nur auf Produktionsabhängigkeiten.
Copilot-Chat kann eine Aktualisierung dependabot.yml schreiben, die den Anforderungen Ihres Teams besser entspricht.
Beispielaufforderung
I want to customize my pull requests for Dependabot security and version updates, so that: * Pull requests are automatically assigned to the team "octocat-reviewers." * The label "security-management" is automatically added to every pull request. * The number of open Dependabot PRs is limited. * Development dependencies are ignored. Draft an update to the dependabot.yml file in my repository that specifies these customization options.
I want to customize my pull requests for Dependabot security and version updates, so that:
* Pull requests are automatically assigned to the team "octocat-reviewers."
* The label "security-management" is automatically added to every pull request.
* The number of open Dependabot PRs is limited.
* Development dependencies are ignored.
Draft an update to the dependabot.yml file in my repository that specifies these customization options.
Tipp
- Es gibt viele Anpassungsoptionen, die du dir ansehen kannst. Weitere Informationen findest du unter Anpassen von Pull Requests für Dependabot-Sicherheitsupdates und Anpassen von Dependabot-Pull-Requests an deine Prozesse.
- Du kannst unterschiedliche Anpassungen pro Paketökosystem angeben.
Beispielausgabe
version: 2
updates:
# Python (pip)
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
day: "sunday"
time: "06:00"
timezone: "UTC"
open-pull-requests-limit: 5
allow:
- dependency-type: "production" # Ignore development dependencies
assignees:
- "octocat-reviewers" # Assign PRs to the team
labels:
- "dependencies"
- "security-management" # Custom label for all PRs
- "python"
commit-message:
prefix: "pip"
ignore:
- dependency-name: "pip"