Skip to content
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

MARP-1294 Create a central monitoring reporting for security issues of axonivy marketplace #251

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from

Conversation

ndkhanh-axonivy
Copy link
Contributor

No description provided.

@github-actions github-actions bot added the enhancement New feature or request label Dec 5, 2024
this.isLoading = false;
}

formatCommitDate(date: string): string {
Copy link
Contributor

Choose a reason for hiding this comment

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

duplicated: similar to time-ago pipe


private handleError(err: any): void {
this.errorMessage =
err.status === 401
Copy link
Contributor

Choose a reason for hiding this comment

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

use const in common.constant.ts

isLoading = false;

private securityMonitorService = inject(SecurityMonitorService);
private readonly githubBaseUrl = 'https://github.com/axonivy-market';
Copy link
Contributor

Choose a reason for hiding this comment

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

github -> gitHub
Should we define a constant?

@@ -0,0 +1,20 @@
export interface Repo {
Copy link
Contributor

Choose a reason for hiding this comment

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

Name of interface does not match to model file.
In BE site, you used ProductSecurityInfo. I think you can use this name for this model

status: string;
alerts: Record<string, number>;
};
secretsScanning: {
Copy link
Contributor

Choose a reason for hiding this comment

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

secretsScanning -> secretScanning

try {
ResponseEntity<List<Map<String, Object>>> response = fetchApiResponseAsList(accessToken,
String.format(GitHubConstants.Url.REPO_DEPENDABOT_ALERTS_OPEN, organization.getLogin(), repo.getName()));
dependabot.setStatus(com.axonivy.market.enums.AccessLevel.ENABLED);
Copy link
Contributor

Choose a reason for hiding this comment

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

Add import static for enum ENABLED instead of using full path of enum class in a method.
Update also for DISABLED and NO_PERMISSION.

}

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public static class Url {
private static final String BASE_URL = "https://api.github.com";
public static final String USER = BASE_URL + "/user";
public static final String REPO_SECURITY_ADVISORIES = BASE_URL + "/repos/%s/%s/security-advisories?state=%s";
Copy link
Contributor

Choose a reason for hiding this comment

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

this constant is not used.

return dependabot;
}

public static SecretScanning getNumberOfSecretScanningAlerts(GHRepository repo, GHOrganization organization,
Copy link
Contributor

Choose a reason for hiding this comment

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

Format code of this method

log.warn(e);
dependabot.setStatus(com.axonivy.market.enums.AccessLevel.NO_PERMISSION);
}
return dependabot;
Copy link
Contributor

Choose a reason for hiding this comment

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

use finally block

return secretScanning;
}

public static CodeScanning getCodeScanningAlerts(GHRepository repo, GHOrganization organization, String accessToken) {
Copy link
Contributor

Choose a reason for hiding this comment

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

similar to getDependabotAlerts(), could you unify them?

expect(service.productId()).toBe('');
});
it('should call API with token and return security details', () => {
const mockToken = 'valid-token';

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical test

The hard-coded value "valid-token" is used as
authorization header
.
service.productNames.set(newProductNames);
expect(service.productNames()).toEqual(newProductNames);
it('should handle error response gracefully', () => {
const mockToken = 'invalid-token';

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical test

The hard-coded value "invalid-token" is used as
authorization header
.
});

it('should call API with token and return security details', () => {
const mockToken = 'valid-token';

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical test

The hard-coded value "valid-token" is used as
authorization header
.
});

it('should handle error response gracefully', () => {
const mockToken = 'invalid-token';

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical test

The hard-coded value "invalid-token" is used as
authorization header
.
Copy link
Contributor

@phhung-axonivy phhung-axonivy left a comment

Choose a reason for hiding this comment

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

Fix sonarqube also

@@ -0,0 +1,227 @@
body {
Copy link
Contributor

Choose a reason for hiding this comment

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

You should not change the styles of the body tag. It can affect the marketplace website.

@@ -18,7 +18,7 @@ import { TimeAgo } from '../enums/time-ago.enum';
})
export class TimeAgoPipe implements PipeTransform {
translateService = inject(TranslateService);
async transform(value?: Date, language?: Language, _args?: []): Promise<string> {
async transform(value?: Date, language: Language = Language.EN, _args?: []): Promise<string> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Check carefully with the time ago of the feature feedback time.


securityInfoList.sort(Comparator.comparing(ProductSecurityInfo::getRepoName));
} catch (IOException e) {
throw new RuntimeException("Error fetching repository data", e);
Copy link
Contributor

Choose a reason for hiding this comment

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

We should log it, and return an empty list when the system cannot fetch a repository

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants