Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Feat/security update august 2023 #661

Merged
merged 86 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
b77b0f5
feat: add default price label when creating issue
wannacfuture Jul 10, 2023
dcb2f53
feat: minor changes
wannacfuture Jul 11, 2023
624826b
feat: permits row security setup
seprintour Aug 3, 2023
d651c9b
fix: add all tables
seprintour Aug 3, 2023
7d4cad6
feat: autopay fix
wannacfuture Aug 4, 2023
785cc64
Merge branch 'development' into feat/autopay-fix
wannacfuture Aug 7, 2023
c5d10b6
feat: minor fix
wannacfuture Aug 7, 2023
4f5bc5a
Merge branch 'feat/autopay-fix' of https://github.com/wannacfuture/ub…
wannacfuture Aug 7, 2023
2cf8827
feat: minor fix
wannacfuture Aug 7, 2023
2b163e6
feat: minor fix
wannacfuture Aug 7, 2023
a8f257d
Merge branch 'development' into feat/autopay-fix
wannacfuture Aug 7, 2023
5c2bc71
Merge branch 'feat/autopay-fix' of https://github.com/wannacfuture/ub…
wannacfuture Aug 7, 2023
4e0ab40
Update src/configs/strings.ts
wannacfuture Aug 7, 2023
0c11d16
Update src/handlers/comment/handlers/index.ts
wannacfuture Aug 7, 2023
0066ade
Merge branch 'feat/autopay-fix' of https://github.com/wannacfuture/ub…
wannacfuture Aug 7, 2023
71548f5
feat: payment permit fix
wannacfuture Aug 7, 2023
7750730
feat: autopay fix
wannacfuture Aug 4, 2023
dc0e4ef
feat: minor fix
wannacfuture Aug 7, 2023
9a6d5de
feat: minor fix
wannacfuture Aug 7, 2023
2203ffb
feat: minor fix
wannacfuture Aug 7, 2023
f6ea50c
Update src/configs/strings.ts
wannacfuture Aug 7, 2023
2234351
Update src/handlers/comment/handlers/index.ts
wannacfuture Aug 7, 2023
b2ddc81
feat: payment permit fix
wannacfuture Aug 7, 2023
fab9755
Merge branch 'feat/autopay-fix' of https://github.com/wannacfuture/ub…
wannacfuture Aug 7, 2023
123ed80
feat: revert parent issue
wannacfuture Aug 7, 2023
a8c0089
feat: minor change
wannacfuture Aug 7, 2023
5d8ff92
feat: default config
wannacfuture Aug 7, 2023
20d4bfd
Update src/handlers/comment/handlers/payout.ts
wannacfuture Aug 7, 2023
79779ec
feat: user permission
wannacfuture Aug 7, 2023
efe2540
Merge branch 'feat/autopay-fix' of https://github.com/wannacfuture/ub…
wannacfuture Aug 7, 2023
9c4f09b
Update ubiquibot-config-default.json
0x4007 Aug 9, 2023
67f6387
feat: import jsonc support
0x4007 Aug 9, 2023
dbb7031
feat: jsonc support
0x4007 Aug 9, 2023
b388897
fix: load jsonc
0x4007 Aug 9, 2023
e243999
fix: other defaults
0x4007 Aug 9, 2023
212eddd
fix: use max integer for defaults
0x4007 Aug 9, 2023
307ffb0
refactor: ordering of properties
0x4007 Aug 9, 2023
3e5d875
feat: full list from mdast
0x4007 Aug 9, 2023
691e79d
refactor: comments
0x4007 Aug 9, 2023
13a49c4
Merge branch 'development' into feat/autopay-fix
0x4007 Aug 9, 2023
e4b3bb2
Update src/handlers/payout/action.ts
0x4007 Aug 9, 2023
9999ffc
Update src/handlers/comment/handlers/payout.ts
0x4007 Aug 9, 2023
9d586a4
feat: minor fix
wannacfuture Aug 9, 2023
ef46849
Merge pull request #579 from wannacfuture/feat/autopay-fix
0x4007 Aug 9, 2023
b2ea8e2
Update ubiquibot-config.yml
0x4007 Aug 9, 2023
9a6f486
Merge branch 'development' into feat/add-default-price-label
wannacfuture Aug 9, 2023
d456927
feat: resolve conflicts
wannacfuture Aug 9, 2023
dd9b3f0
feat: fixed minor bugs
wannacfuture Aug 10, 2023
1579293
Update src/configs/strings.ts
wannacfuture Aug 10, 2023
f13face
Update src/configs/strings.ts
wannacfuture Aug 10, 2023
ddfef0f
Merge branch 'development' into feat/parent-issue-fix
wannacfuture Aug 10, 2023
bfee1dd
feat: resolve conflicts
wannacfuture Aug 10, 2023
105547f
Merge pull request #597 from wannacfuture/feat/parent-issue-fix
0x4007 Aug 10, 2023
674ada5
feat: slight change
wannacfuture Aug 10, 2023
53a23d3
feat: minor fix
wannacfuture Aug 10, 2023
f819542
Merge branch 'development' into feat/parent-issue-fix
wannacfuture Aug 10, 2023
505719f
Merge pull request #596 from ubiquity/pavlovcik-patch-2
0x4007 Aug 10, 2023
2abac46
Merge pull request #578 from seprintour/setup-policies
0x4007 Aug 10, 2023
1dc05fc
Merge branch 'development' into feat/parent-issue-fix
wannacfuture Aug 10, 2023
182c273
Update src/handlers/pricing/action.ts
wannacfuture Aug 10, 2023
144ed37
Update src/handlers/payout/action.ts
wannacfuture Aug 10, 2023
43194ed
Merge pull request #598 from wannacfuture/feat/parent-issue-fix
0x4007 Aug 10, 2023
dfb48b1
Merge pull request #484 from wannacfuture/feat/add-default-price-label
0xcodercrane Aug 11, 2023
7e9c469
fix: make it optional
0xcodercrane Aug 12, 2023
c1b218a
chore: make persistSession false
0xcodercrane Aug 12, 2023
82a2e26
chore: any type
0xcodercrane Aug 12, 2023
d4d6a8d
fix: query regex
EtherealGlow Aug 12, 2023
6aa91c8
fix: query regex
EtherealGlow Aug 12, 2023
59a6fc7
Update query.ts
EtherealGlow Aug 12, 2023
6268d44
fix: query regex
EtherealGlow Aug 12, 2023
a2daa60
fix: query regex
EtherealGlow Aug 12, 2023
bb80223
fix: switch back to json and remove strip-json-comments dependency
0x4007 Aug 12, 2023
61b4dd0
Merge branch 'development' into pavlovcik-patch-1
0x4007 Aug 12, 2023
2e31b3f
Merge pull request #594 from ubiquity/pavlovcik-patch-1
0x4007 Aug 13, 2023
24c11e7
Merge pull request #611 from EtherealGlow/development-7
0x4007 Aug 13, 2023
d4e2b96
chore: better logging
0xcodercrane Aug 14, 2023
33a17f0
chore: new migration
0xcodercrane Aug 14, 2023
e9cfb82
Merge pull request #614 from ubiquity/complete-row-security
0xcodercrane Aug 14, 2023
838e7a4
feat: new policy
0xcodercrane Aug 14, 2023
84657d0
fix: with check
0xcodercrane Aug 14, 2023
2051c1d
fix: insert policy
0xcodercrane Aug 14, 2023
202a831
chore: docs update
0xcodercrane Aug 14, 2023
d56a523
chore: revert due to use of service key
0xcodercrane Aug 14, 2023
59825e4
fix: check permission when closing issue (#622)
wannacfuture Aug 17, 2023
a3001a9
Merge commit '59825e4d7289a8da87bb3f568d9e69b183c821cf' into HEAD
0x4007 Aug 23, 2023
237686b
Update src/adapters/supabase/helpers/client.ts
0x4007 Aug 23, 2023
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
15 changes: 7 additions & 8 deletions .github/ubiquibot-config.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
---
evm-network-id: 100
price-multiplier: 1.5
time-labels:
- name: "Time: <1 Hour"
weight: 0.125
value: 3600
- name: "Time: <2 Hours"
weight: 0.25
value: 7200
- name: "Time: <4 Hours"
weight: 0.5
value: 14400
- name: "Time: <1 Day"
weight: 1
value: 86400
- name: "Time: <1 Week"
weight: 2
value: 604800
- name: "Time: <2 Weeks"
weight: 3
value: 1209600
- name: "Time: <1 Month"
weight: 4
value: 2592000
priority-labels:
- name: "Priority: 0 (Normal)"
weight: 1
Expand All @@ -31,9 +30,9 @@ priority-labels:
default-labels:
- "Time: <1 Hour"
- "Priority: 0 (Normal)"
- "Test"
payment-permit-max-price: 1000
comment-incentives: true
max-concurrent-bounties: 2
promotion-comment: "\n<h6>If you enjoy the DevPool experience, please follow <a href='https://github.com/ubiquity'>Ubiquity on GitHub</a> and star <a href='https://github.com/ubiquity/devpool-directory'>this repo</a> to show your support. It helps a lot!</h6>"
register-wallet-with-verification: false
assistive-pricing: true
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,20 @@ Bounty bot is built using the [probot](https://probot.github.io/) framework so i
|
├── <a href="https://github.com/ubiquity/ubiquibot/tree/development/src/utils">utils</a> A set of utility functions
</pre>

## Default Config Notes (`ubiquibot-config-default.json`)

We can't use a `jsonc` file due to limitations with Netlify. Here is a snippet of some values with notes next to them.

```jsonc
{
"payment-permit-max-price": 9007199254740991, // Number.MAX_SAFE_INTEGER
"max-concurrent-assigns": 9007199254740991, // Number.MAX_SAFE_INTEGER
"comment-element-pricing": {
/* https://github.com/syntax-tree/mdast#nodes */
"strong": 0 // Also includes italics, unfortunately https://github.com/syntax-tree/mdast#strong
/* https://github.com/syntax-tree/mdast#gfm */

}
}
```
4 changes: 2 additions & 2 deletions src/adapters/supabase/helpers/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { BigNumber, BigNumberish } from "ethers";
* @returns - The supabase client
*/
export const supabase = (url: string, key: string): SupabaseClient => {
return createClient<Database>(url, key);
return createClient<Database>(url, key, { auth: { persistSession: false } });
};

/**
Expand Down Expand Up @@ -175,7 +175,7 @@ export const upsertWalletAddress = async (username: string, address: string): Pr
created_at: new Date().toUTCString(),
updated_at: new Date().toUTCString(),
});
logger.info(`Creating a new wallet_table record done, { data: ${_data}, error: ${_error} }`);
logger.info(`Creating a new wallet_table record done, { data: ${_data}, error: ${_error?.message} }`);
}
};

Expand Down
4 changes: 4 additions & 0 deletions src/configs/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ export const GLOBAL_STRINGS = {
unassignComment: "Releasing the bounty back to dev pool because the allocated duration already ended!",
askUpdate: "Do you have any updates",
assignCommandDisabledComment: "The `/assign` command is disabled for this repository.",
skipPriceLabelGenerationComment: "Pricing is disabled on parent issues.",
ignoreStartCommandForParentIssueComment:
"Please select a child issue from the specification checklist to work on. The `/start` command is disabled on parent issues.",
autopayComment: "Automatic payment for this issue is enabled:",
};
1 change: 1 addition & 0 deletions src/handlers/comment/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export enum IssueCommentCommands {
// Access Controls

ALLOW = "/allow",
AUTOPAY = "/autopay",
}
6 changes: 6 additions & 0 deletions src/handlers/comment/handlers/assign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getWalletAddress, getWalletMultiplier } from "../../../adapters/supabas
import { tableComment } from "./table";
import { bountyInfo } from "../../wildcard";
import { ASSIGN_COMMAND_ENABLED, GLOBAL_STRINGS } from "../../../configs";
import { isParentIssue } from "../../pricing";

export const assign = async (body: string) => {
const { payload: _payload } = getBotContext();
Expand All @@ -29,6 +30,11 @@ export const assign = async (body: string) => {
return GLOBAL_STRINGS.assignCommandDisabledComment;
}

if (issue.body && isParentIssue(issue.body)) {
logger.info(`Ignore '/start' command from user: identified as parent issue`);
return GLOBAL_STRINGS.ignoreStartCommandForParentIssueComment;
}

const openedPullRequests = await getAvailableOpenedPullRequests(payload.sender.login);
logger.info(`Opened Pull Requests with approved reviews or with no reviews but over 24 hours have passed: ${JSON.stringify(openedPullRequests)}`);

Expand Down
26 changes: 19 additions & 7 deletions src/handlers/comment/handlers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import {
import { getBotConfig, getBotContext, getLogger } from "../../../bindings";
import { handleIssueClosed } from "../../payout";
import { query } from "./query";
import { autoPay } from "./payout";
import { getTargetPriceLabel } from "../../shared";

export * from "./assign";
export * from "./wallet";
Expand Down Expand Up @@ -95,15 +97,19 @@ export const issueCreatedCallback = async (): Promise<void> => {
const timeLabels = config.price.timeLabels.filter((item) => labels.map((i) => i.name).includes(item.name));
const priorityLabels = config.price.priorityLabels.filter((item) => labels.map((i) => i.name).includes(item.name));

if (timeLabels.length === 0 && priorityLabels.length === 0) {
for (const label of config.price.defaultLabels) {
const exists = await getLabel(label);
if (!exists) await createLabel(label);
await addLabelToIssue(label);
}
const minTimeLabel = timeLabels.length > 0 ? timeLabels.reduce((a, b) => (a.weight < b.weight ? a : b)).name : config.price.defaultLabels[0];
const minPriorityLabel = priorityLabels.length > 0 ? priorityLabels.reduce((a, b) => (a.weight < b.weight ? a : b)).name : config.price.defaultLabels[1];
if (!timeLabels.length) await addLabelToIssue(minTimeLabel);
if (!priorityLabels.length) await addLabelToIssue(minPriorityLabel);

const targetPriceLabel = getTargetPriceLabel(minTimeLabel, minPriorityLabel);
if (targetPriceLabel && !labels.map((i) => i.name).includes(targetPriceLabel)) {
const exist = await getLabel(targetPriceLabel);
if (!exist) await createLabel(targetPriceLabel, "price");
await addLabelToIssue(targetPriceLabel);
}
} catch (err: unknown) {
return await addCommentToIssue(`Error: ${err}`, issue.number);
await addCommentToIssue(`Error: ${err}`, issue.number);
}
};

Expand Down Expand Up @@ -225,6 +231,12 @@ export const userCommands = (): UserCommands[] => {
handler: payout,
callback: commandCallback,
},*/
{
id: IssueCommentCommands.AUTOPAY,
description: "Toggle automatic payment for the completion of the current issue.",
handler: autoPay,
callback: commandCallback,
},
{
id: IssueCommentCommands.QUERY,
description: `Comments the users multiplier and address`,
Expand Down
26 changes: 25 additions & 1 deletion src/handlers/comment/handlers/payout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { getBotContext, getLogger } from "../../../bindings";
import { Payload } from "../../../types";
import { IssueCommentCommands } from "../commands";
import { handleIssueClosed } from "../../payout";
import { getAllIssueComments } from "../../../helpers";
import { getAllIssueComments, getUserPermission } from "../../../helpers";
import { GLOBAL_STRINGS } from "../../../configs";

export const payout = async (body: string) => {
const { payload: _payload } = getBotContext();
Expand Down Expand Up @@ -40,3 +41,26 @@ export const payout = async (body: string) => {
const response = await handleIssueClosed();
return response;
};

export const autoPay = async (body: string) => {
const context = getBotContext();
const _payload = context.payload;
const logger = getLogger();

const payload = _payload as Payload;
logger.info(`Received '/autopay' command from user: ${payload.sender.login}`);

const pattern = /^\/autopay (true|false)$/;
const res = body.match(pattern);

if (res) {
const userPermission = await getUserPermission(payload.sender.login, context);
if (userPermission !== "admin" && userPermission !== "billing_manager") {
return "You must be an `admin` or `billing_manager` to toggle automatic payments for completed issues.";
}
if (res.length > 1) {
return `${GLOBAL_STRINGS.autopayComment} **${res[1]}**`;
}
}
return "Invalid body for autopay command: e.g. /autopay false";
};
2 changes: 1 addition & 1 deletion src/handlers/comment/handlers/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const query = async (body: string) => {
return `Skipping '/query' because of no issue instance`;
}

const regex = /^\/query\s@(\w+)$/;
const regex = /^\/query\s+@([\w-]+)\s*$/;
const matches = body.match(regex);
const user = matches?.[1];

Expand Down
34 changes: 32 additions & 2 deletions src/handlers/payout/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { getPenalty, getWalletAddress, getWalletMultiplier, removePenalty } from
import { getBotConfig, getBotContext, getLogger } from "../../bindings";
import {
addLabelToIssue,
checkUserPermissionForRepoAndOrg,
clearAllPriceLabelsOnIssue,
deleteLabel,
generatePermit2Signature,
getAllIssueAssignEvents,
Expand All @@ -14,6 +16,8 @@ import {
import { UserType, Payload, StateReason } from "../../types";
import { shortenEthAddress } from "../../utils";
import { bountyInfo } from "../wildcard";
import { GLOBAL_STRINGS } from "../../configs";
import { isParentIssue } from "../pricing";

export const handleIssueClosed = async () => {
const context = getBotContext();
Expand All @@ -30,11 +34,15 @@ export const handleIssueClosed = async () => {

if (!issue) return;

const userHasPermission = await checkUserPermissionForRepoAndOrg(payload.sender.login, context);

if (!userHasPermission) return "Permit generation skipped because this issue has been closed by an external contributor.";

const comments = await getAllIssueComments(issue.number);

const wasReopened = await wasIssueReopened(issue.number);
const claimUrlRegex = new RegExp(`\\((${permitBaseUrl}\\?claim=\\S+)\\)`);
const permitCommentIdx = comments.findIndex((e) => e.user.type === "Bot" && e.body.match(claimUrlRegex));
const permitCommentIdx = comments.findIndex((e) => e.user.type === UserType.Bot && e.body.match(claimUrlRegex));

if (wasReopened && permitCommentIdx !== -1) {
const permitComment = comments[permitCommentIdx];
Expand Down Expand Up @@ -87,8 +95,30 @@ export const handleIssueClosed = async () => {
return "Permit generation skipped because the issue was not closed as completed";
}

logger.info(`Checking if the issue is a parent issue.`);
if (issue.body && isParentIssue(issue.body)) {
logger.error("Permit generation skipped since the issue is identified as parent issue.");
await clearAllPriceLabelsOnIssue();
return "Permit generation skipped since the issue is identified as parent issue.";
}

logger.info(`Handling issues.closed event, issue: ${issue.number}`);
if (paymentPermitMaxPrice == 0) {
for (const botComment of comments.filter((cmt) => cmt.user.type === UserType.Bot).reverse()) {
const botCommentBody = botComment.body;
if (botCommentBody.includes(GLOBAL_STRINGS.autopayComment)) {
const pattern = /\*\*(\w+)\*\*/;
const res = botCommentBody.match(pattern);
if (res) {
if (res[1] === "false") {
logger.info(`Skipping to generate permit2 url, reason: autoPayMode for this issue: false`);
return `Permit generation skipped since automatic payment for this issue is disabled.`;
}
break;
}
}
}

if (paymentPermitMaxPrice == 0 || !paymentPermitMaxPrice) {
logger.info(`Skipping to generate permit2 url, reason: { paymentPermitMaxPrice: ${paymentPermitMaxPrice}}`);
return `Permit generation skipped since paymentPermitMaxPrice is 0`;
}
Expand Down
18 changes: 17 additions & 1 deletion src/handlers/pricing/action.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { getBotConfig, getBotContext, getLogger } from "../../bindings";
import { addLabelToIssue, clearAllPriceLabelsOnIssue, createLabel, getLabel } from "../../helpers";
import { GLOBAL_STRINGS } from "../../configs";
import { addCommentToIssue, addLabelToIssue, clearAllPriceLabelsOnIssue, createLabel, getLabel } from "../../helpers";
import { Payload } from "../../types";
import { handleLabelsAccess } from "../access";
import { getTargetPriceLabel } from "../shared";
Expand All @@ -12,6 +13,16 @@ export const pricingLabelLogic = async (): Promise<void> => {
if (!payload.issue) return;
const labels = payload.issue.labels;

logger.info(`Checking if the issue is a parent issue.`);
if (payload.issue.body && isParentIssue(payload.issue.body)) {
logger.error("Identified as parent issue. Disabling price label.");
const issuePrices = labels.filter((label) => label.name.toString().startsWith("Price:"));
if (issuePrices.length) {
await addCommentToIssue(GLOBAL_STRINGS.skipPriceLabelGenerationComment, payload.issue.number);
await clearAllPriceLabelsOnIssue();
}
return;
}
const valid = await handleLabelsAccess();

if (!valid) {
Expand Down Expand Up @@ -46,3 +57,8 @@ export const pricingLabelLogic = async (): Promise<void> => {
logger.info(`Skipping action...`);
}
};

export const isParentIssue = (body: string) => {
const parentPattern = /-\s+\[( |x)\]\s+#\d+/;
Copy link
Member Author

@0x4007 0x4007 Aug 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just checking for a checklist? This should look for the UI element when GitHub shows that it is a "tracking issue" of other issues?

@wannacfuture bfee1dd rfc

Copy link
Contributor

@wannacfuture wannacfuture Aug 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, usually parent issue conatins this string:
- [ ] #issue_number.
and it is checking it via regexp

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this achieved the specification. I was concerned about this UI element but perhaps it isn't necessary to implement.

return body.match(parentPattern);
};
43 changes: 43 additions & 0 deletions src/helpers/issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,49 @@ export const removeAssignees = async (issue_number: number, assignees: string[])
}
};

export const checkUserPermissionForRepoAndOrg = async (username: string, context: Context): Promise<boolean> => {
const permissionForRepo = await checkUserPermissionForRepo(username, context);
const permissionForOrg = await checkUserPermissionForOrg(username, context);

return permissionForOrg || permissionForRepo;
};

export const checkUserPermissionForRepo = async (username: string, context: Context): Promise<boolean> => {
const logger = getLogger();
const payload = context.payload as Payload;

try {
const res = await context.octokit.rest.repos.checkCollaborator({
owner: payload.repository.owner.login,
repo: payload.repository.name,
username,
});

return res.status === 204;
} catch (e: unknown) {
logger.error(`Checking if user permisson for repo failed!, reason: ${e}`);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return false;
}
};

export const checkUserPermissionForOrg = async (username: string, context: Context): Promise<boolean> => {
const logger = getLogger();
const payload = context.payload as Payload;
if (!payload.organization) return false;

try {
const res = await context.octokit.rest.orgs.checkMembershipForUser({
org: payload.organization.login,
username,
});
// @ts-expect-error This looks like a bug in octokit. (https://github.com/octokit/rest.js/issues/188)
return res.status === 204;
} catch (e: unknown) {
logger.error(`Checking if user permisson for org failed!, reason: ${e}`);
return false;
}
};

export const getUserPermission = async (username: string, context: Context): Promise<string> => {
const logger = getLogger();
const payload = context.payload as Payload;
Expand Down
1 change: 1 addition & 0 deletions src/types/payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ const IssueSchema = Type.Object({
events_url: Type.String(),
html_url: Type.String(),
id: Type.Number(),
body: Type.Any(),
node_id: Type.String(),
number: Type.Number(),
title: Type.String(),
Expand Down
3 changes: 2 additions & 1 deletion supabase/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@ For more information about arguments, please go through [here](https://supabase.
### Database Operation

- `supabase migration new MIGRATION_NAME`: It will create a migration file in supabase/migrations folder.
- `supabase db push -p PASSWORD`: Update database schema on supabase platform
- `supabase migration repair <MIGRATION_NAME> --status reverted`: Revert a given migration file.
- `supabase db push`: Update database schema on supabase platform
- `supabase gen types typescript > src/adapters/supabase/types/database.ts --linked`: Generate typescript types from the supabase project linked
13 changes: 13 additions & 0 deletions supabase/migrations/20230803154507_setup_permits_policies.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ALTER TABLE permits ENABLE ROW LEVEL SECURITY;
ALTER TABLE wallets ENABLE ROW LEVEL SECURITY;
ALTER TABLE users ENABLE ROW LEVEL SECURITY;
ALTER TABLE issues ENABLE ROW LEVEL SECURITY;
ALTER TABLE weekly ENABLE ROW LEVEL SECURITY;
ALTER TABLE access ENABLE ROW LEVEL SECURITY;
ALTER TABLE penalty ENABLE ROW LEVEL SECURITY;
ALTER TABLE multiplier ENABLE ROW LEVEL SECURITY;

CREATE POLICY "Enable read access for frontend" ON "public"."permits"
AS PERMISSIVE FOR SELECT
TO public
USING (true)
Loading