Skip to content

Commit

Permalink
cid-31656: Remove the name of the file on the webhook events
Browse files Browse the repository at this point in the history
  • Loading branch information
henriq-amaral-leanix committed Nov 6, 2024
1 parent 81de853 commit 7f0ff20
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import net.leanix.githubagent.dto.Trigger
import net.leanix.githubagent.exceptions.JwtTokenNotFound
import net.leanix.githubagent.exceptions.ManifestFileNotFoundException
import net.leanix.githubagent.shared.MANIFEST_FILE_NAME
import net.leanix.githubagent.shared.fileNameMatchRegex
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service
import java.util.UUID
Expand All @@ -26,7 +27,6 @@ class GitHubScanningService(
private val gitHubAuthenticationService: GitHubAuthenticationService,
private val syncLogService: SyncLogService
) {
val fileNameMatchRegex = Regex("/?$MANIFEST_FILE_NAME\$")

private val logger = LoggerFactory.getLogger(GitHubScanningService::class.java)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import net.leanix.githubagent.dto.ManifestFileUpdateDto
import net.leanix.githubagent.dto.PushEventCommit
import net.leanix.githubagent.dto.PushEventPayload
import net.leanix.githubagent.shared.MANIFEST_FILE_NAME
import net.leanix.githubagent.shared.fileNameMatchRegex
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service

Expand Down Expand Up @@ -124,7 +125,7 @@ class WebhookEventService(
repositoryFullName,
action,
fileContent,
manifestFilePath
fileNameMatchRegex.replace(manifestFilePath, "")
)
)
}
Expand All @@ -138,7 +139,7 @@ class WebhookEventService(
repositoryFullName,
ManifestFileAction.REMOVED,
null,
manifestFilePath
fileNameMatchRegex.replace(manifestFilePath, "")
)
)
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/net/leanix/githubagent/shared/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ val SUPPORTED_EVENT_TYPES = listOf(
"ORGANIZATION",
"INSTALLATION",
)

val fileNameMatchRegex = Regex("/?$MANIFEST_FILE_NAME\$")
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class WebhookEventServiceTest {
"owner/repo",
ManifestFileAction.MODIFIED,
"content",
MANIFEST_FILE_NAME
""
)
)
}
Expand Down Expand Up @@ -179,7 +179,7 @@ class WebhookEventServiceTest {
"owner/repo",
ManifestFileAction.REMOVED,
null,
"a/b/c/$MANIFEST_FILE_NAME"
"a/b/c"
)
)
}
Expand Down Expand Up @@ -212,7 +212,7 @@ class WebhookEventServiceTest {
"owner/repo",
ManifestFileAction.ADDED,
"content",
"a/b/c/$MANIFEST_FILE_NAME"
"a/b/c"
)
)
}
Expand Down Expand Up @@ -245,7 +245,7 @@ class WebhookEventServiceTest {
"owner/repo",
ManifestFileAction.ADDED,
"content",
"custom/path/added1/$MANIFEST_FILE_NAME"
"custom/path/added1"
)
)
webSocketService.sendMessage(
Expand All @@ -254,7 +254,7 @@ class WebhookEventServiceTest {
"owner/repo",
ManifestFileAction.ADDED,
"content",
"custom/path/added2/$MANIFEST_FILE_NAME"
"custom/path/added2"
)
)
webSocketService.sendMessage(
Expand All @@ -263,7 +263,7 @@ class WebhookEventServiceTest {
"owner/repo",
ManifestFileAction.MODIFIED,
"content",
"custom/path/modified/$MANIFEST_FILE_NAME"
"custom/path/modified"
)
)
}
Expand Down Expand Up @@ -296,7 +296,7 @@ class WebhookEventServiceTest {
"owner/repo",
ManifestFileAction.ADDED,
"content",
"custom/path/added2/$MANIFEST_FILE_NAME"
"custom/path/added2"
)
)
}
Expand Down

0 comments on commit 7f0ff20

Please sign in to comment.