Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ For example:
## PR check list

- [ ] As much as possible, the changes include tests
- [ ] If the changes affect the end user (new feature, behavior change, bug fix) then the PR has a changelog entry.

- [ ] If the changes affect the end user (new feature, behavior change, bug fix) then the PR has a changelog entry.
12 changes: 12 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ on:
- "README.md"

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Run pre-commit
run: pipx run pre-commit run --all-files --show-diff-on-failure
env:
# SKIP ggshield check: it's done by the "scanning" job
SKIP: ggshield

build-and-test:
runs-on: ${{ matrix.os }}
strategy:
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
default_stages: [pre-commit]
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: v6.0.0
hooks:
# not python related
- id: check-added-large-files
Expand All @@ -11,7 +11,7 @@ repos:
args: [--allow-multiple-documents]

- repo: https://github.com/commitizen-tools/commitizen
rev: v3.12.0
rev: v4.9.1
hooks:
- id: commitizen
# don't forget to run pre-commit install --hook-type commit-msg for this hook to run
Expand All @@ -24,13 +24,13 @@ repos:
- id: prettier

- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
rev: v2.4.1
hooks:
- id: codespell
exclude: ^(ggshield-internal)

- repo: https://github.com/gitguardian/ggshield
rev: v1.36.0
rev: v1.43.0
hooks:
- id: ggshield
language_version: python3
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Whether you’re a solo developer or part of a team, GitGuardian scales with you

- **Ignore Secrets**: After a scan, hover over the identified secret and select "GitGuardian: Ignore Secret" to add it to `.gitguardian.yaml`.
- **Quota Tracking**: Run "GitGuardian: Show Quota" to monitor API call usage. Personal accounts include up to 10,000 monthly API calls.
- **Check API Quota**: Stay aware of usage by running "GitGuardian: Show Quota."
- **Check API Quota**: Stay aware of usage by running "GitGuardian: Show Quota."

### Support & Contributions

Expand All @@ -33,4 +33,4 @@ Whether you’re a solo developer or part of a team, GitGuardian scales with you
### Release Notes & License

- **Updates**: See the [Changelog](https://github.com/GitGuardian/gitguardian-vscode/blob/main/CHANGELOG.md).
- **License**: GitGuardian CLI (`ggshield`) and this extension are MIT licensed.
- **License**: GitGuardian CLI (`ggshield`) and this extension are MIT licensed.
42 changes: 21 additions & 21 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,33 +39,33 @@ import {

function registerOpenViewsCommands(
context: ExtensionContext,
outputChannel: any
outputChannel: any,
) {
const showOutputCommand = commands.registerCommand(
"gitguardian.showOutput",
() => {
outputChannel.show();
}
},
);

const openSidebarCommand = commands.registerCommand(
"gitguardian.openSidebar",
() => {
commands.executeCommand("workbench.view.extension.gitguardian");
}
},
);

const openProblemsCommand = commands.registerCommand(
"gitguardian.openProblems",
() => {
commands.executeCommand("workbench.actions.view.problems");
}
},
);

context.subscriptions.push(
showOutputCommand,
openSidebarCommand,
openProblemsCommand
openProblemsCommand,
);
}

Expand All @@ -76,50 +76,50 @@ export async function activate(context: ExtensionContext) {
const ggshieldResolver = new GGShieldResolver(
outputChannel,
context,
configuration
configuration,
);
const ggshieldViewProvider = new GitGuardianWebviewProvider(
configuration,
context.extensionUri,
context
context,
);

const ggshieldRemediationMessageViewProvider =
new GitGuardianRemediationMessageWebviewProvider(
configuration,
context.extensionUri,
context
context,
);
const ggshieldQuotaViewProvider = new GitGuardianQuotaWebviewProvider(
configuration,
context.extensionUri,
context
context,
);
window.registerWebviewViewProvider("gitguardianView", ggshieldViewProvider);
window.registerWebviewViewProvider(
"gitguardianRemediationMessageView",
ggshieldRemediationMessageViewProvider
ggshieldRemediationMessageViewProvider,
);
window.registerWebviewViewProvider(
"gitguardianQuotaView",
ggshieldQuotaViewProvider
ggshieldQuotaViewProvider,
);
context.subscriptions.push(
ggshieldViewProvider,
ggshieldRemediationMessageViewProvider,
ggshieldQuotaViewProvider
ggshieldQuotaViewProvider,
);

createStatusBarItem(context);

//generic commands to open correct view on status bar click
registerOpenViewsCommands(context, outputChannel);
commands.registerCommand("gitguardian.refreshQuota", () =>
ggshieldQuotaViewProvider.refresh()
ggshieldQuotaViewProvider.refresh(),
);

context.subscriptions.push(
languages.registerHoverProvider("*", new GitGuardianSecretHoverProvider())
languages.registerHoverProvider("*", new GitGuardianSecretHoverProvider()),
);

if (!checkGitInstalled()) {
Expand Down Expand Up @@ -149,12 +149,12 @@ export async function activate(context: ExtensionContext) {
scanFile(
textDocument.fileName,
textDocument.uri,
ggshieldResolver.configuration
ggshieldResolver.configuration,
);
}
}),
workspace.onDidCloseTextDocument((textDocument) =>
cleanUpFileDiagnostics(textDocument.uri)
cleanUpFileDiagnostics(textDocument.uri),
),
commands.registerCommand("gitguardian.quota", () => {
showAPIQuota(ggshieldResolver.configuration);
Expand All @@ -173,12 +173,12 @@ export async function activate(context: ExtensionContext) {
ignoreSecret(
ggshieldResolver.configuration,
diagnosticData.secretSha,
secretName
secretName,
);
scanFile(
currentFile,
Uri.file(currentFile),
ggshieldResolver.configuration
ggshieldResolver.configuration,
);
}),
commands.registerCommand("gitguardian.authenticate", async () => {
Expand All @@ -187,7 +187,7 @@ export async function activate(context: ExtensionContext) {
ggshieldResolver.configuration,
outputChannel,
ggshieldViewProvider.getView() as WebviewView,
context
context,
)
.then(async () => {
await updateAuthenticationStatus(context, configuration);
Expand All @@ -212,8 +212,8 @@ export async function activate(context: ExtensionContext) {
ggshieldViewProvider.refresh();
ggshieldRemediationMessageViewProvider.refresh();
ggshieldQuotaViewProvider.refresh();
}
)
},
),
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/ggshield-webview/gitguardian-quota-webview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ export class GitGuardianQuotaWebviewProvider
constructor(
private ggshieldConfiguration: GGShieldConfiguration,
private readonly _extensionUri: vscode.Uri,
private context: vscode.ExtensionContext
private context: vscode.ExtensionContext,
) {}

public resolveWebviewView(
webviewView: vscode.WebviewView,
context: vscode.WebviewViewResolveContext,
_token: vscode.CancellationToken
_token: vscode.CancellationToken,
) {
this._view = webviewView;
this.refresh();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ export class GitGuardianRemediationMessageWebviewProvider
constructor(
private ggshieldConfiguration: GGShieldConfiguration,
private readonly _extensionUri: vscode.Uri,
private context: vscode.ExtensionContext
private context: vscode.ExtensionContext,
) {
this.updateRemediationMessage();
}

public resolveWebviewView(
webviewView: vscode.WebviewView,
context: vscode.WebviewViewResolveContext,
_token: vscode.CancellationToken
_token: vscode.CancellationToken,
) {
this._view = webviewView;
this.refresh();
Expand All @@ -38,7 +38,7 @@ export class GitGuardianRemediationMessageWebviewProvider
private checkAuthenticationStatus() {
this.isAuthenticated = this.context.workspaceState.get(
"authenticationStatus",
false
false,
);
}

Expand Down
18 changes: 9 additions & 9 deletions src/ggshield-webview/gitguardian-webview-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ import { AuthenticationStatus, ConfigSource } from "../lib/authentication";
import { GGShieldConfiguration } from "../lib/ggshield-configuration";

const projectDiscussionUri = vscode.Uri.parse(
"https://github.com/GitGuardian/gitguardian-vscode/discussions"
"https://github.com/GitGuardian/gitguardian-vscode/discussions",
);
const projectIssuesUri = vscode.Uri.parse(
"https://github.com/GitGuardian/gitguardian-vscode/issues"
"https://github.com/GitGuardian/gitguardian-vscode/issues",
);
const feedbackFormUri = vscode.Uri.parse(
"https://docs.google.com/forms/d/e/1FAIpQLSc_BemGrdQfxp6lg7KgeDoB32XZg8yMfapk2gbemu0mVfskDQ/viewform"
"https://docs.google.com/forms/d/e/1FAIpQLSc_BemGrdQfxp6lg7KgeDoB32XZg8yMfapk2gbemu0mVfskDQ/viewform",
);
const documentationUri = vscode.Uri.parse(
"https://docs.gitguardian.com/ggshield-docs/configuration"
"https://docs.gitguardian.com/ggshield-docs/configuration",
);

export class GitGuardianWebviewProvider implements vscode.WebviewViewProvider {
Expand All @@ -22,13 +22,13 @@ export class GitGuardianWebviewProvider implements vscode.WebviewViewProvider {
constructor(
private ggshieldConfiguration: GGShieldConfiguration,
private readonly _extensionUri: vscode.Uri,
private context: vscode.ExtensionContext
private context: vscode.ExtensionContext,
) {}

public resolveWebviewView(
webviewView: vscode.WebviewView,
context: vscode.WebviewViewResolveContext,
_token: vscode.CancellationToken
_token: vscode.CancellationToken,
) {
this._view = webviewView;

Expand Down Expand Up @@ -61,14 +61,14 @@ export class GitGuardianWebviewProvider implements vscode.WebviewViewProvider {
const webview = this._view.webview;

const styleUri = webview.asWebviewUri(
vscode.Uri.joinPath(this._extensionUri, "media", "main.css")
vscode.Uri.joinPath(this._extensionUri, "media", "main.css"),
);
const logoUri = webview.asWebviewUri(
vscode.Uri.joinPath(
this._extensionUri,
"images",
"gitguardian-icon-primary700-background.svg"
)
"gitguardian-icon-primary700-background.svg",
),
);

console.log(authenticationStatus);
Expand Down
8 changes: 4 additions & 4 deletions src/gitguardian-interface/gitguardian-hover-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export class GitGuardianSecretHoverProvider implements vscode.HoverProvider {
public provideHover(
document: vscode.TextDocument,
position: vscode.Position,
token: vscode.CancellationToken
token: vscode.CancellationToken,
): vscode.ProviderResult<vscode.Hover> {
const diagnostics = vscode.languages.getDiagnostics(document.uri);

Expand All @@ -20,7 +20,7 @@ export class GitGuardianSecretHoverProvider implements vscode.HoverProvider {
const encodedDiagnosticData = encodeURIComponent(diagnosticData);

hoverMessage.appendMarkdown(
`[GitGuardian: Ignore Secret (update .gitguardian.yaml)](command:gitguardian.ignoreSecret?${encodedDiagnosticData} "Click to ignore this incident")`
`[GitGuardian: Ignore Secret (update .gitguardian.yaml)](command:gitguardian.ignoreSecret?${encodedDiagnosticData} "Click to ignore this incident")`,
);
return new vscode.Hover(hoverMessage, diagnostic.range);
}
Expand Down Expand Up @@ -65,9 +65,9 @@ function extractInfosFromMessage(message: string): {

export function generateSecretName(
currentFile: string,
uriDiagnostic: any
uriDiagnostic: any,
): string {
return `${uriDiagnostic.detector} - ${vscode.workspace.asRelativePath(
currentFile
currentFile,
)}:l.${uriDiagnostic.startLine}`;
}
22 changes: 12 additions & 10 deletions src/lib/api-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ export type Validity =
| "invalid"
| "valid";

type IncidentVaultProperties = {
secret_vaulted: false;
} | {
secret_vaulted: true;
vault_type: string;
vault_name: string;
vault_path: string;
vault_path_count: number;
}
type IncidentVaultProperties =
| {
secret_vaulted: false;
}
| {
secret_vaulted: true;
vault_type: string;
vault_name: string;
vault_path: string;
vault_path_count: number;
};

export type Incident = {
type: string;
Expand All @@ -34,7 +36,7 @@ export type Incident = {
known_secret: boolean;
incident_url: string;
total_occurrences: number;
} & IncidentVaultProperties
} & IncidentVaultProperties;

export interface EntityWithIncidents {
incidents: Incident[];
Expand Down
Loading
Loading