forked from JayPNanduri/ast-cli-javascript-wrapper-jay
-
Notifications
You must be signed in to change notification settings - Fork 3
Changes regarding sha verification #207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cx-atish-jadhav
wants to merge
1
commit into
main
Choose a base branch
from
other/release-integration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,16 +32,6 @@ export class CxInstaller { | |
| linux: { platform: linuxOS, extension: 'tar.gz' } | ||
| }; | ||
|
|
||
| // Default version and its paired SHA-256 checksums, keyed by "platform_architecture". | ||
| // Update both together when bumping the default CLI version. | ||
| private readonly cliDefaultVersion = '2.3.48'; | ||
| private static readonly cliDefaultChecksums: Record<string, string> = { | ||
| 'windows_x64': '441ee8df46cc630ae000f8ba73925113aeed8c4d16cf274944aff3e7197e3470', | ||
| 'darwin_x64': 'b72f7e4ca14e5e56600b07d22c848a4b85e7c37d2e595424340cc699ea10006b', | ||
| 'linux_x64': 'eb3eb55add37f150188f5a8b36b2a659f902ad9569dcb7ee652531fe525022e2', | ||
| 'linux_arm64': '7df61689b3c2bbd4c27face5bdc0da97f63e4533229d6b53dd777f90d3904931', | ||
| 'linux_armv6': '99659f2e0804b197550efc6a9ddb6029babc980d32bdfeeb508199247ac95878' | ||
| }; | ||
|
|
||
| constructor(platform: string, client: AstClient) { | ||
| this.platform = platform as SupportedPlatforms; | ||
|
|
@@ -50,8 +40,7 @@ export class CxInstaller { | |
| } | ||
|
|
||
| // Returns the CLI version and its platform-specific SHA-256 checksum. | ||
| // Tries the version file and checksums file first; falls back to the | ||
| // hardcoded defaults if the version file is absent or empty. | ||
| // Reads from version and checksums files. Throws CxError if version is absent or version file is empty. | ||
| // Result is cached after the first read. | ||
| async readASTCLIVersion(): Promise<{ version: string; checksum: string | null }> { | ||
| if (this.cliVersion) { | ||
|
|
@@ -68,24 +57,23 @@ export class CxInstaller { | |
| const trimmed = content.trim(); | ||
| if (trimmed) version = trimmed; | ||
| } catch { | ||
| // version file absent — fall through to defaults | ||
| // version file absent — will throw error below | ||
| } | ||
|
|
||
| let checksum: string | null; | ||
| if (version === null) { | ||
| version = this.cliDefaultVersion; | ||
| checksum = CxInstaller.cliDefaultChecksums[key] ?? null; | ||
| } else { | ||
| try { | ||
| const content = await fsPromises.readFile(this.getChecksumsFilePath(), 'utf-8'); | ||
| checksum = (JSON.parse(content) as Record<string, string>)[key] ?? null; | ||
| if (checksum === null) { | ||
| logger.warn(`No checksum found for ${key} in checksums file. Download will not be verified.`); | ||
| } | ||
| } catch { | ||
| logger.warn(`Checksums file not found. Download of version ${version} will not be verified.`); | ||
| checksum = null; | ||
| throw new CxError(`CLI version not found`); | ||
| } | ||
|
|
||
| let checksum: string | null; | ||
| try { | ||
| const content = await fsPromises.readFile(this.getChecksumsFilePath(), 'utf-8'); | ||
| checksum = (JSON.parse(content) as Record<string, string>)[key] ?? null; | ||
| if (checksum === null) { | ||
| logger.warn(`No checksum found for ${key} in checksums file. Download will not be verified.`); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should throw an exception here. Valid checksum is not found. |
||
| } | ||
| } catch { | ||
| logger.warn(`Checksums file not found. Download of version ${version} will not be verified.`); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here also throw an exception |
||
| checksum = null; | ||
| } | ||
|
|
||
| this.cliVersion = version; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we have empty catch block ?