-
Notifications
You must be signed in to change notification settings - Fork 36
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
Support JFrog Apps Config file #405
Conversation
585c00f
to
4a35ae8
Compare
4a35ae8
to
5fb3c9f
Compare
5fb3c9f
to
f72e977
Compare
f72e977
to
7721d45
Compare
7721d45
to
410eca7
Compare
410eca7
to
e932a0d
Compare
e932a0d
to
0053b0c
Compare
0053b0c
to
d72ec62
Compare
d72ec62
to
35b6b08
Compare
6a65fec
to
0f91072
Compare
894053e
to
ff77065
Compare
ff77065
to
9706616
Compare
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.
@yahavi, excellent work!. You have significantly improved the clarity and structure of the code 🚀.
@@ -128,23 +122,16 @@ export class ScanManager implements ExtensionComponent { | |||
return !ScanManager.lastOutdatedCheck || Date.now() - ScanManager.lastOutdatedCheck > ScanManager.RESOURCE_CHECK_UPDATE_INTERVAL_MILLISECS; | |||
} | |||
|
|||
private getResources(supportedScans: SupportedScans): Resource[] { | |||
private getResources(supportedScans: EntitledScans): Resource[] { |
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.
'Resource' is a vague name that refers to any artifact that is downloaded from Artifactory. The 'Resource' in 'scanManager' talks about a specific resource which is the JasRunners. I suggest we use the most descriptive name we can and replace 'Resource' with 'JasRunners'
} | ||
|
||
/** | ||
* Updates all the resources that are outdated. | ||
* @param supportedScans - the supported scan to get the needed resources. if default, should call getSupportedScans before calling this method. | ||
* @returns true if all the outdated resources updated successfully, false otherwise | ||
*/ | ||
public async updateResources(supportedScans: SupportedScans = this._supportedScans): Promise<boolean> { | ||
public async updateResources(supportedScans: EntitledScans = this._entitledScans): Promise<boolean> { |
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.
I have a couple of quistions regarding the param:
-
Given that its name suggests that
ScanManager
is responsible for managing all scans, why is it necessary to pass in the supported scan as a parameter? As a manager, one would expect it to handle all aspects of the scan without revealing internal implementation details to other functions. A manager should inherently know what is supported or not. -
The only reference I could find, calling this func is at 'IssuesTreeDataProvider'. Why data providers should care about scan manager updates? again, no one can tell a manager what to do regarding internal details that are being used for scans operations.
let resources: Resource[] = []; | ||
if (supportedScans.applicability || supportedScans.iac || supportedScans.secrets) { | ||
resources.push(BinaryRunner.getAnalyzerManagerResource(this._logManager)); | ||
resources.push(JasRunner.getAnalyzerManagerResource(this._logManager)); | ||
} else { | ||
this.logManager.logMessage('You are not entitled to run Advanced Security scans', 'DEBUG'); |
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.
Could we identify if we are not entitled before calling getResources
at getSupportedScans
?
} | ||
|
||
/** | ||
* Get all the entitlement status for each type of scan the manager offers | ||
*/ | ||
public async getSupportedScans(): Promise<SupportedScans> { | ||
let supportedScans: SupportedScans = {} as SupportedScans; | ||
public async getSupportedScans(): Promise<EntitledScans> { |
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.
I suggest that we change it to be private, and each support check will be response to update it own property
For example:
public async isApplicabilitySupported(): Promise<boolean> {
return await ConnectionUtils.testXrayEntitlementForFeature(this._connectionManager.createJfrogClient(), EntitlementScanFeature.Applicability);
}
--->
public async setApplicabilityEntitled(): Promise<void> {
ConnectionUtils.testXrayEntitlementForFeature(this._connectionManager.createJfrogClient(), EntitlementScanFeature.Applicability)
.then(res => (this.entitledScans.applicability = res))
.catch(err => ScanUtils.onScanError(err, this._logManager, true))
}
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.
I think the suggestion is not related to Apps Config and not to the changes I did in this PR.
This PR has already become too big.
describe('JFrog Apps Config Tests', () => { | ||
const jfrogAppsConfigDir: string = path.join(__dirname, '..', 'resources', 'jfrogAppsConfig'); | ||
|
||
it('Load full config', () => { |
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.
We can break the test into two separate tests, each with its own particular assertion. for example, a check sast scanner can be encapsulated in its own it().
It will be clearer what fails in the config and it will enable us to scale if we would like to add additional specific module tests
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.
The bond between the tests is too strong to split them into subtests - it reads one file and parses it. This is the result of the parsing. If we add more tests, it will require creating another input yaml and by that a new it.
I do agree that the test method was too long and therefore I shorted the test.
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.
Maybe we can move the file read logic into the before
section, each it
will check a specific configuration section. Adding a new section to the config file in the future will make us add a single it
test case.
npm run format
for formatting the code before submitting the pull request..jfrog/jfrog-apps-config.yml
file to allow configuring JFrog Advanced Security scanners. https://github.com/jfrog/jfrog-apps-config