Skip to content

Commit

Permalink
Fix Sonar Security and ci/cd issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sayoungestguy committed Oct 18, 2024
1 parent fd5eebd commit a33345b
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion script/zap-script.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

docker pull zaproxy/zap-stable
docker run -i zaproxy/zap-stable zap-baseline.py -t "https://github.com/sayoungestguy/scaleup" -l PASS > ./target/test-reports/zap_baseline_report.html
docker run -i zaproxy/zap-stable zap-baseline.py -t "https://github.com/sayoungestguy/scaleup" -l PASS > zap_baseline_report.html

echo $? > /dev/null
2 changes: 2 additions & 0 deletions src/main/java/com/teamsixnus/scaleup/domain/Activity.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class Activity extends AbstractAuditingEntity<Long> implements Serializab
private static final long serialVersionUID = 1L;

@Id
@NotNull
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
Expand Down Expand Up @@ -216,6 +217,7 @@ public boolean equals(Object o) {
if (!(o instanceof Activity)) {
return false;
}

return getId() != null && getId().equals(((Activity) o).getId());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.Instant;
import org.hibernate.annotations.Cache;
Expand Down Expand Up @@ -164,7 +165,7 @@ public boolean equals(Object o) {
if (!(o instanceof ActivityInvite)) {
return false;
}
return getId() != null && getId().equals(((ActivityInvite) o).getId());
return id != null && id.equals(((ActivityInvite) o).id);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public boolean equals(Object o) {
if (!(o instanceof CodeTables)) {
return false;
}
return getId() != null && getId().equals(((CodeTables) o).getId());
return id != null && id.equals(((CodeTables) o).id);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/teamsixnus/scaleup/domain/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public boolean equals(Object o) {
if (!(o instanceof Message)) {
return false;
}
return getId() != null && getId().equals(((Message) o).getId());
return id != null && id.equals(((Message) o).id);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/teamsixnus/scaleup/domain/Skill.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public boolean equals(Object o) {
if (!(o instanceof Skill)) {
return false;
}
return getId() != null && getId().equals(((Skill) o).getId());
return id != null && id.equals(((Skill) o).id);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class UserProfile extends AbstractAuditingEntity<Long> implements Seriali

//edited by wei jie, original function above
@Id
@NotNull
@Column(name = "id")
private Long id;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/teamsixnus/scaleup/domain/UserSkill.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public boolean equals(Object o) {
if (!(o instanceof UserSkill)) {
return false;
}
return getId() != null && getId().equals(((UserSkill) o).getId());
return id != null && id.equals(((UserSkill) o).id);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
@WithMockUser
class UserSkillResourceIT {

private static final Long DEFAULT_ID = 1L;

private static final Integer DEFAULT_YEARS_OF_EXPERIENCE = 1;
private static final Integer UPDATED_YEARS_OF_EXPERIENCE = 2;
private static final Integer SMALLER_YEARS_OF_EXPERIENCE = 1 - 1;
Expand Down Expand Up @@ -105,6 +107,9 @@ public void cleanup() {
@Transactional
void createUserSkill() throws Exception {
long databaseSizeBeforeCreate = getRepositoryCount();

// Ensure the entity has no ID before creation (it will be auto-generated)
assertThat(userSkill.getId()).isNull();
// Create the UserSkill
UserSkillDTO userSkillDTO = userSkillMapper.toDto(userSkill);
var returnedUserSkillDTO = om.readValue(
Expand All @@ -122,6 +127,9 @@ void createUserSkill() throws Exception {
var returnedUserSkill = userSkillMapper.toEntity(returnedUserSkillDTO);
assertUserSkillUpdatableFieldsEquals(returnedUserSkill, getPersistedUserSkill(returnedUserSkill));

// The ID must be auto-generated and not null after persistence
assertThat(returnedUserSkill.getId()).isNotNull();

insertedUserSkill = returnedUserSkill;
}

Expand Down

0 comments on commit a33345b

Please sign in to comment.