Skip to content

Commit

Permalink
Remove out-by-one license workround (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
cosdon authored Aug 1, 2023
1 parent 5459f15 commit b07b6b0
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 45 deletions.
11 changes: 3 additions & 8 deletions dist/nowsecure-convert-sarif/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38930,7 +38930,7 @@ class NowSecure {
* Checks if the assessment limit has been reached. Throws an exception if
* an error occurs.
*/
isLicenseValid(licenseWorkaround) {
isLicenseValid() {
return __awaiter(this, void 0, void 0, function* () {
const r = yield __classPrivateFieldGet(this, _NowSecure_client, "f").getJson(`${__classPrivateFieldGet(this, _NowSecure_apiUrl, "f")}/graphql?query={${LICENSE_GQL}}`);
if (r.statusCode !== 200) {
Expand All @@ -38940,13 +38940,8 @@ class NowSecure {
const error = r.result.errors[0];
throw new Error(`Report request failed with error: ${error}`);
}
const { total, limit, reached } = r.result.data.my.user.organization.usage.assessment;
let limitReached = reached;
if (licenseWorkaround) {
// FIXME: Workaround platform license counting issue.
limitReached = limit !== -1 && total + 1 >= limit;
}
return !limitReached;
const { reached } = r.result.data.my.user.organization.usage.assessment;
return !reached;
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion dist/nowsecure-convert-sarif/index.js.map

Large diffs are not rendered by default.

11 changes: 3 additions & 8 deletions dist/nowsecure-create-issues/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46065,7 +46065,7 @@ class NowSecure {
* Checks if the assessment limit has been reached. Throws an exception if
* an error occurs.
*/
isLicenseValid(licenseWorkaround) {
isLicenseValid() {
return __awaiter(this, void 0, void 0, function* () {
const r = yield __classPrivateFieldGet(this, _NowSecure_client, "f").getJson(`${__classPrivateFieldGet(this, _NowSecure_apiUrl, "f")}/graphql?query={${LICENSE_GQL}}`);
if (r.statusCode !== 200) {
Expand All @@ -46075,13 +46075,8 @@ class NowSecure {
const error = r.result.errors[0];
throw new Error(`Report request failed with error: ${error}`);
}
const { total, limit, reached } = r.result.data.my.user.organization.usage.assessment;
let limitReached = reached;
if (licenseWorkaround) {
// FIXME: Workaround platform license counting issue.
limitReached = limit !== -1 && total + 1 >= limit;
}
return !limitReached;
const { reached } = r.result.data.my.user.organization.usage.assessment;
return !reached;
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion dist/nowsecure-create-issues/index.js.map

Large diffs are not rendered by default.

14 changes: 4 additions & 10 deletions dist/nowsecure-upload-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32021,7 +32021,7 @@ class NowSecure {
* Checks if the assessment limit has been reached. Throws an exception if
* an error occurs.
*/
isLicenseValid(licenseWorkaround) {
isLicenseValid() {
return __awaiter(this, void 0, void 0, function* () {
const r = yield __classPrivateFieldGet(this, _NowSecure_client, "f").getJson(`${__classPrivateFieldGet(this, _NowSecure_apiUrl, "f")}/graphql?query={${LICENSE_GQL}}`);
if (r.statusCode !== 200) {
Expand All @@ -32031,13 +32031,8 @@ class NowSecure {
const error = r.result.errors[0];
throw new Error(`Report request failed with error: ${error}`);
}
const { total, limit, reached } = r.result.data.my.user.organization.usage.assessment;
let limitReached = reached;
if (licenseWorkaround) {
// FIXME: Workaround platform license counting issue.
limitReached = limit !== -1 && total + 1 >= limit;
}
return !limitReached;
const { reached } = r.result.data.my.user.organization.usage.assessment;
return !reached;
});
}
}
Expand Down Expand Up @@ -32497,9 +32492,8 @@ function run() {
const groupId = core.getInput("group_id");
const appFile = core.getInput("app_file");
const versionString = core.getInput("version_string");
const licenseWorkaround = core.getBooleanInput("license_workaround");
const analysisType = core.getInput("analysis_type");
const licenseValid = yield ns.isLicenseValid(licenseWorkaround);
const licenseValid = yield ns.isLicenseValid();
if (!licenseValid) {
throw new Error("Assessment limit reached");
}
Expand Down
2 changes: 1 addition & 1 deletion dist/nowsecure-upload-app/index.js.map

Large diffs are not rendered by default.

13 changes: 3 additions & 10 deletions src/nowsecure-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export class NowSecure {
* Checks if the assessment limit has been reached. Throws an exception if
* an error occurs.
*/
async isLicenseValid(licenseWorkaround: boolean): Promise<boolean> {
async isLicenseValid(): Promise<boolean> {
const r = await this.#client.getJson<PullReportResponse>(
`${this.#apiUrl}/graphql?query={${LICENSE_GQL}}`
);
Expand All @@ -250,15 +250,8 @@ export class NowSecure {
throw new Error(`Report request failed with error: ${error}`);
}

const { total, limit, reached } =
r.result.data.my.user.organization.usage.assessment;
const { reached } = r.result.data.my.user.organization.usage.assessment;

let limitReached = reached;
if (licenseWorkaround) {
// FIXME: Workaround platform license counting issue.
limitReached = limit !== -1 && total + 1 >= limit;
}

return !limitReached;
return !reached;
}
}
3 changes: 1 addition & 2 deletions src/nowsecure-upload-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ async function run() {
const groupId = core.getInput("group_id");
const appFile = core.getInput("app_file");
const versionString = core.getInput("version_string");
const licenseWorkaround = core.getBooleanInput("license_workaround");
const analysisType = core.getInput("analysis_type");

const licenseValid = await ns.isLicenseValid(licenseWorkaround);
const licenseValid = await ns.isLicenseValid();
if (!licenseValid) {
throw new Error("Assessment limit reached");
}
Expand Down
4 changes: 0 additions & 4 deletions upload-app/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ inputs:
group_id:
required: true
description: "Group ID for the application in Platform."
license_workaround:
required: true
description: "Workaround for improved license limit reached UX."
default: true
version_string:
required: false
description: "Version string to associate with the build"
Expand Down

0 comments on commit b07b6b0

Please sign in to comment.