Skip to content

Commit

Permalink
addressing note CodeQL alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
theztefan committed Apr 26, 2024
1 parent 16acc45 commit fac8a0b
Show file tree
Hide file tree
Showing 14 changed files with 4 additions and 36 deletions.
15 changes: 0 additions & 15 deletions dist/github/Utils.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49519,7 +49519,6 @@ const run = async () => {
let report = new Report_1.Report();
report.addInput(inputs);
report.addPolicy(policies);
const policyEvaluator = null;
// depending on which input.level is provided, run the appropriate checks
if (inputs.level === "organization") {
Logger_1.logger.info("Running org level checks");
Expand Down
1 change: 0 additions & 1 deletion dist/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ const run = async () => {
let report = new Report_1.Report();
report.addInput(inputs);
report.addPolicy(policies);
const policyEvaluator = null;
// depending on which input.level is provided, run the appropriate checks
if (inputs.level === "organization") {
Logger_1.logger.info("Running org level checks");
Expand Down
1 change: 0 additions & 1 deletion src/evaluators/OrgPolicyEvaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { OrgGHASChecks } from "./organization/OrgGHASChecks";
import { OrgAuthenticationChecks } from "./organization/OrgAuthenticationChecks";
import { OrgCustomRolesChecks } from "./organization/OrgCustomRolesChecks";
import { getOrganization } from "../github/Organization";
import { FilesExistChecks } from "./multipurpose/FilesExistChecks";
import { PrivilegesChecks } from "./organization/PrivilegesChecks";

export class OrgPolicyEvaluator {
Expand Down
1 change: 0 additions & 1 deletion src/evaluators/organization/OrgCustomRolesChecks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Organization, CheckResult } from "../../types/common/main";
import { getCustomRolesForOrg } from "../../github/Organization";
import { logger } from "../../utils/Logger";

export class OrgCustomRolesChecks {
private policy: any;
Expand Down
1 change: 0 additions & 1 deletion src/evaluators/organization/OrgGHASChecks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Organization, CheckResult } from "../../types/common/main";
import { getSecurityTeamsForOrg } from "../../github/Organization";
import { logger } from "../../utils/Logger";

export class OrgGHASChecks {
private policy: any;
Expand Down
2 changes: 0 additions & 2 deletions src/evaluators/repository/ActionsChecks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { CheckResult, Repository } from "../../types/common/main";
import {
getRepoActionsPermissions,
getRepoSelectedActions,
getRepoWorkflows,
getRepoWorkflowActions,
} from "../../github/Actions";
import { logger } from "../../utils/Logger";

Expand Down
2 changes: 0 additions & 2 deletions src/evaluators/repository/WebHooksChecks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { CheckResult, Repository } from "../../types/common/main";
import { getWebHooks, getWebHookConfig } from "../../github/WebHooks";
import { logger } from "../../utils/Logger";

export class WebHooksChecks {
private policy: any;
Expand All @@ -18,7 +17,6 @@ export class WebHooksChecks {
this.repository.name,
);


// for each webhook in webhooks extract the domain and check if it is in the allowed list in the policy, if not return false

const allowedDomains = this.policy.webhooks.allowed_domains;
Expand Down
1 change: 0 additions & 1 deletion src/github/Actions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Endpoints } from "@octokit/types";
import { GitArmorKit } from "./GitArmorKit";
import { logger } from "../utils/Logger";
import { getRepoFile } from "./Utils";

//Get GitHub Actions permissions for a repository
export const getRepoActionsPermissions = async (
Expand Down
1 change: 0 additions & 1 deletion src/github/Issues.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Issue } from "../types/common/main";
import { GitArmorKit } from "./GitArmorKit";

// export class to Issues class
Expand Down
5 changes: 2 additions & 3 deletions src/github/Repositories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@ export const getRepository = async (
repo: string,
): Promise<Endpoints["GET /repos/{owner}/{repo}"]["response"]["data"]> => {
const octokit = new GitArmorKit();

const response: Endpoints["GET /repos/{owner}/{repo}"]["response"] =
await octokit.rest.repos.get({
owner: owner,
repo: repo,
});

return response.data;

return response.data;
};

export const getRepoPullRequests = async (
Expand Down
1 change: 0 additions & 1 deletion src/github/Utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Endpoints } from "@octokit/types";
import { GitArmorKit } from "./GitArmorKit";
import { logger } from "../utils/Logger";

//Given a certain path in a repository, get the contents of the file
export const getRepoFile = async (
Expand Down
5 changes: 1 addition & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ import { Report } from "./reporting/Report";
import { RepoPolicy, OrgPolicy, Repository } from "./types/common/main";
import { loadPolicy } from "./utils/policies";
import * as core from "@actions/core";
import { summary } from "@actions/core/lib/summary";

const run = async (): Promise<void> => {

console.log(`
GitArmor
Expand All @@ -27,7 +25,6 @@ const run = async (): Promise<void> => {
let report = new Report();
report.addInput(inputs);
report.addPolicy(policies);
const policyEvaluator = null;
// depending on which input.level is provided, run the appropriate checks
if (inputs.level === "organization") {
logger.info("Running org level checks");
Expand Down Expand Up @@ -72,7 +69,7 @@ const run = async (): Promise<void> => {
repository,
policies.repo as RepoPolicy,
);

await policyEvaluator.evaluatePolicy();
policyEvaluator.printCheckResults();
report.addOneRepoEvaluator(policyEvaluator);
Expand Down
3 changes: 1 addition & 2 deletions src/reporting/Report.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { CheckResult, Policy, Inputs } from "../types/common/main";
import { Policy, Inputs } from "../types/common/main";
import { OrgPolicyEvaluator } from "../evaluators/OrgPolicyEvaluator";
import { RepoPolicyEvaluator } from "../evaluators/RepoPolicyEvaluator";
import { logger } from "./../utils/Logger";
import fs from "fs";
import { json } from "stream/consumers";

export class Report {
private orgEvaluators: Map<OrgPolicyEvaluator, RepoPolicyEvaluator[]>;
Expand Down

0 comments on commit fac8a0b

Please sign in to comment.