Skip to content

Commit 0b39312

Browse files
Remove user info from ssh git repo urls (DataDog#6275)
1 parent c2b3e05 commit 0b39312

16 files changed

Lines changed: 2030 additions & 42 deletions

File tree

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/ci/CIInfo.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package datadog.trace.civisibility.ci;
22

3+
import static datadog.trace.api.git.GitUtils.filterSensitiveInfo;
4+
35
import java.util.HashMap;
46
import java.util.Map;
57
import java.util.Objects;
@@ -87,7 +89,7 @@ public Builder ciEnvVars(String... ciEnvVarKeysArray) {
8789

8890
ciEnvVars = new HashMap<>();
8991
for (String ciEnvVarKey : ciEnvVarKeysArray) {
90-
final String envVarVal = System.getenv(ciEnvVarKey);
92+
final String envVarVal = filterSensitiveInfo(System.getenv(ciEnvVarKey));
9193
if (envVarVal != null && !envVarVal.isEmpty()) {
9294
ciEnvVars.put(ciEnvVarKey, envVarVal);
9395
}

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/ci/GithubActionsInfo.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package datadog.trace.civisibility.ci;
22

3+
import static datadog.trace.api.git.GitUtils.filterSensitiveInfo;
34
import static datadog.trace.api.git.GitUtils.isTagReference;
45
import static datadog.trace.api.git.GitUtils.normalizeBranch;
56
import static datadog.trace.api.git.GitUtils.normalizeTag;
@@ -28,7 +29,8 @@ class GithubActionsInfo implements CIProviderInfo {
2829
@Override
2930
public GitInfo buildCIGitInfo() {
3031
return new GitInfo(
31-
buildGitRepositoryUrl(System.getenv(GHACTIONS_URL), System.getenv(GHACTIONS_REPOSITORY)),
32+
buildGitRepositoryUrl(
33+
filterSensitiveInfo(System.getenv(GHACTIONS_URL)), System.getenv(GHACTIONS_REPOSITORY)),
3234
buildGitBranch(),
3335
buildGitTag(),
3436
new CommitInfo(System.getenv(GHACTIONS_SHA)));
@@ -38,13 +40,13 @@ public GitInfo buildCIGitInfo() {
3840
public CIInfo buildCIInfo() {
3941
final String pipelineUrl =
4042
buildPipelineUrl(
41-
System.getenv(GHACTIONS_URL),
43+
filterSensitiveInfo(System.getenv(GHACTIONS_URL)),
4244
System.getenv(GHACTIONS_REPOSITORY),
4345
System.getenv(GHACTIONS_PIPELINE_ID),
4446
System.getenv(GHACTIONS_PIPELINE_RETRY));
4547
final String jobUrl =
4648
buildJobUrl(
47-
System.getenv(GHACTIONS_URL),
49+
filterSensitiveInfo(System.getenv(GHACTIONS_URL)),
4850
System.getenv(GHACTIONS_REPOSITORY),
4951
System.getenv(GHACTIONS_SHA));
5052

dd-java-agent/agent-ci-visibility/src/test/resources/ci/azurepipelines.json

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,5 +677,201 @@
677677
"git.commit.message": "azure-pipelines-commit-message",
678678
"git.repository_url": "https://dev.azure.com/fabrikamfiber/repo.git"
679679
}
680+
],
681+
[
682+
{
683+
"BUILD_BUILDID": "azure-pipelines-build-id",
684+
"BUILD_DEFINITIONNAME": "azure-pipelines-name",
685+
"BUILD_REPOSITORY_URI": "https://user:password@dev.azure.com:1234/fabrikamfiber/repo.git",
686+
"BUILD_REQUESTEDFOREMAIL": "azure-pipelines-commit-author-email@datadoghq.com",
687+
"BUILD_REQUESTEDFORID": "azure-pipelines-commit-author",
688+
"BUILD_SOURCEVERSIONMESSAGE": "azure-pipelines-commit-message",
689+
"SYSTEM_JOBID": "azure-pipelines-job-id",
690+
"SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id",
691+
"SYSTEM_TEAMFOUNDATIONSERVERURI": "https://azure-pipelines-server-uri.com/",
692+
"SYSTEM_TEAMPROJECTID": "azure-pipelines-project-id",
693+
"TF_BUILD": "True"
694+
},
695+
{
696+
"_dd.ci.env_vars": "{\"SYSTEM_TEAMPROJECTID\":\"azure-pipelines-project-id\",\"BUILD_BUILDID\":\"azure-pipelines-build-id\",\"SYSTEM_JOBID\":\"azure-pipelines-job-id\"}",
697+
"ci.job.url": "https://azure-pipelines-server-uri.com/azure-pipelines-project-id/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id",
698+
"ci.pipeline.id": "azure-pipelines-build-id",
699+
"ci.pipeline.name": "azure-pipelines-name",
700+
"ci.pipeline.number": "azure-pipelines-build-id",
701+
"ci.pipeline.url": "https://azure-pipelines-server-uri.com/azure-pipelines-project-id/_build/results?buildId=azure-pipelines-build-id",
702+
"ci.provider.name": "azurepipelines",
703+
"git.commit.author.email": "azure-pipelines-commit-author-email@datadoghq.com",
704+
"git.commit.author.name": "azure-pipelines-commit-author",
705+
"git.commit.message": "azure-pipelines-commit-message",
706+
"git.repository_url": "https://dev.azure.com:1234/fabrikamfiber/repo.git"
707+
}
708+
],
709+
[
710+
{
711+
"BUILD_BUILDID": "azure-pipelines-build-id",
712+
"BUILD_DEFINITIONNAME": "azure-pipelines-name",
713+
"BUILD_REPOSITORY_URI": "https://user:password@1.1.1.1:1234/fabrikamfiber/repo.git",
714+
"BUILD_REQUESTEDFOREMAIL": "azure-pipelines-commit-author-email@datadoghq.com",
715+
"BUILD_REQUESTEDFORID": "azure-pipelines-commit-author",
716+
"BUILD_SOURCEVERSIONMESSAGE": "azure-pipelines-commit-message",
717+
"SYSTEM_JOBID": "azure-pipelines-job-id",
718+
"SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id",
719+
"SYSTEM_TEAMFOUNDATIONSERVERURI": "https://azure-pipelines-server-uri.com/",
720+
"SYSTEM_TEAMPROJECTID": "azure-pipelines-project-id",
721+
"TF_BUILD": "True"
722+
},
723+
{
724+
"_dd.ci.env_vars": "{\"SYSTEM_TEAMPROJECTID\":\"azure-pipelines-project-id\",\"BUILD_BUILDID\":\"azure-pipelines-build-id\",\"SYSTEM_JOBID\":\"azure-pipelines-job-id\"}",
725+
"ci.job.url": "https://azure-pipelines-server-uri.com/azure-pipelines-project-id/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id",
726+
"ci.pipeline.id": "azure-pipelines-build-id",
727+
"ci.pipeline.name": "azure-pipelines-name",
728+
"ci.pipeline.number": "azure-pipelines-build-id",
729+
"ci.pipeline.url": "https://azure-pipelines-server-uri.com/azure-pipelines-project-id/_build/results?buildId=azure-pipelines-build-id",
730+
"ci.provider.name": "azurepipelines",
731+
"git.commit.author.email": "azure-pipelines-commit-author-email@datadoghq.com",
732+
"git.commit.author.name": "azure-pipelines-commit-author",
733+
"git.commit.message": "azure-pipelines-commit-message",
734+
"git.repository_url": "https://1.1.1.1:1234/fabrikamfiber/repo.git"
735+
}
736+
],
737+
[
738+
{
739+
"BUILD_BUILDID": "azure-pipelines-build-id",
740+
"BUILD_DEFINITIONNAME": "azure-pipelines-name",
741+
"BUILD_REPOSITORY_URI": "https://user:password@1.1.1.1:1234/fabrikamfiber/repo_with_@_yeah.git",
742+
"BUILD_REQUESTEDFOREMAIL": "azure-pipelines-commit-author-email@datadoghq.com",
743+
"BUILD_REQUESTEDFORID": "azure-pipelines-commit-author",
744+
"BUILD_SOURCEVERSIONMESSAGE": "azure-pipelines-commit-message",
745+
"SYSTEM_JOBID": "azure-pipelines-job-id",
746+
"SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id",
747+
"SYSTEM_TEAMFOUNDATIONSERVERURI": "https://azure-pipelines-server-uri.com/",
748+
"SYSTEM_TEAMPROJECTID": "azure-pipelines-project-id",
749+
"TF_BUILD": "True"
750+
},
751+
{
752+
"_dd.ci.env_vars": "{\"SYSTEM_TEAMPROJECTID\":\"azure-pipelines-project-id\",\"BUILD_BUILDID\":\"azure-pipelines-build-id\",\"SYSTEM_JOBID\":\"azure-pipelines-job-id\"}",
753+
"ci.job.url": "https://azure-pipelines-server-uri.com/azure-pipelines-project-id/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id",
754+
"ci.pipeline.id": "azure-pipelines-build-id",
755+
"ci.pipeline.name": "azure-pipelines-name",
756+
"ci.pipeline.number": "azure-pipelines-build-id",
757+
"ci.pipeline.url": "https://azure-pipelines-server-uri.com/azure-pipelines-project-id/_build/results?buildId=azure-pipelines-build-id",
758+
"ci.provider.name": "azurepipelines",
759+
"git.commit.author.email": "azure-pipelines-commit-author-email@datadoghq.com",
760+
"git.commit.author.name": "azure-pipelines-commit-author",
761+
"git.commit.message": "azure-pipelines-commit-message",
762+
"git.repository_url": "https://1.1.1.1:1234/fabrikamfiber/repo_with_@_yeah.git"
763+
}
764+
],
765+
[
766+
{
767+
"BUILD_BUILDID": "azure-pipelines-build-id",
768+
"BUILD_DEFINITIONNAME": "azure-pipelines-name",
769+
"BUILD_REPOSITORY_URI": "https://user@dev.azure.com/fabrikamfiber/repo.git",
770+
"BUILD_REQUESTEDFOREMAIL": "azure-pipelines-commit-author-email@datadoghq.com",
771+
"BUILD_REQUESTEDFORID": "azure-pipelines-commit-author",
772+
"BUILD_SOURCEVERSIONMESSAGE": "azure-pipelines-commit-message",
773+
"SYSTEM_JOBID": "azure-pipelines-job-id",
774+
"SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id",
775+
"SYSTEM_TEAMFOUNDATIONSERVERURI": "https://azure-pipelines-server-uri.com/",
776+
"SYSTEM_TEAMPROJECTID": "azure-pipelines-project-id",
777+
"TF_BUILD": "True"
778+
},
779+
{
780+
"_dd.ci.env_vars": "{\"SYSTEM_TEAMPROJECTID\":\"azure-pipelines-project-id\",\"BUILD_BUILDID\":\"azure-pipelines-build-id\",\"SYSTEM_JOBID\":\"azure-pipelines-job-id\"}",
781+
"ci.job.url": "https://azure-pipelines-server-uri.com/azure-pipelines-project-id/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id",
782+
"ci.pipeline.id": "azure-pipelines-build-id",
783+
"ci.pipeline.name": "azure-pipelines-name",
784+
"ci.pipeline.number": "azure-pipelines-build-id",
785+
"ci.pipeline.url": "https://azure-pipelines-server-uri.com/azure-pipelines-project-id/_build/results?buildId=azure-pipelines-build-id",
786+
"ci.provider.name": "azurepipelines",
787+
"git.commit.author.email": "azure-pipelines-commit-author-email@datadoghq.com",
788+
"git.commit.author.name": "azure-pipelines-commit-author",
789+
"git.commit.message": "azure-pipelines-commit-message",
790+
"git.repository_url": "https://dev.azure.com/fabrikamfiber/repo.git"
791+
}
792+
],
793+
[
794+
{
795+
"BUILD_BUILDID": "azure-pipelines-build-id",
796+
"BUILD_DEFINITIONNAME": "azure-pipelines-name",
797+
"BUILD_REPOSITORY_URI": "ssh://user@host.xz:port/path/to/repo.git/",
798+
"BUILD_REQUESTEDFOREMAIL": "azure-pipelines-commit-author-email@datadoghq.com",
799+
"BUILD_REQUESTEDFORID": "azure-pipelines-commit-author",
800+
"BUILD_SOURCEVERSIONMESSAGE": "azure-pipelines-commit-message",
801+
"SYSTEM_JOBID": "azure-pipelines-job-id",
802+
"SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id",
803+
"SYSTEM_TEAMFOUNDATIONSERVERURI": "https://azure-pipelines-server-uri.com/",
804+
"SYSTEM_TEAMPROJECTID": "azure-pipelines-project-id",
805+
"TF_BUILD": "True"
806+
},
807+
{
808+
"_dd.ci.env_vars": "{\"SYSTEM_TEAMPROJECTID\":\"azure-pipelines-project-id\",\"BUILD_BUILDID\":\"azure-pipelines-build-id\",\"SYSTEM_JOBID\":\"azure-pipelines-job-id\"}",
809+
"ci.job.url": "https://azure-pipelines-server-uri.com/azure-pipelines-project-id/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id",
810+
"ci.pipeline.id": "azure-pipelines-build-id",
811+
"ci.pipeline.name": "azure-pipelines-name",
812+
"ci.pipeline.number": "azure-pipelines-build-id",
813+
"ci.pipeline.url": "https://azure-pipelines-server-uri.com/azure-pipelines-project-id/_build/results?buildId=azure-pipelines-build-id",
814+
"ci.provider.name": "azurepipelines",
815+
"git.commit.author.email": "azure-pipelines-commit-author-email@datadoghq.com",
816+
"git.commit.author.name": "azure-pipelines-commit-author",
817+
"git.commit.message": "azure-pipelines-commit-message",
818+
"git.repository_url": "ssh://host.xz:port/path/to/repo.git/"
819+
}
820+
],
821+
[
822+
{
823+
"BUILD_BUILDID": "azure-pipelines-build-id",
824+
"BUILD_DEFINITIONNAME": "azure-pipelines-name",
825+
"BUILD_REPOSITORY_URI": "ssh://user:password@host.xz:port/path/to/repo.git/",
826+
"BUILD_REQUESTEDFOREMAIL": "azure-pipelines-commit-author-email@datadoghq.com",
827+
"BUILD_REQUESTEDFORID": "azure-pipelines-commit-author",
828+
"BUILD_SOURCEVERSIONMESSAGE": "azure-pipelines-commit-message",
829+
"SYSTEM_JOBID": "azure-pipelines-job-id",
830+
"SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id",
831+
"SYSTEM_TEAMFOUNDATIONSERVERURI": "https://azure-pipelines-server-uri.com/",
832+
"SYSTEM_TEAMPROJECTID": "azure-pipelines-project-id",
833+
"TF_BUILD": "True"
834+
},
835+
{
836+
"_dd.ci.env_vars": "{\"SYSTEM_TEAMPROJECTID\":\"azure-pipelines-project-id\",\"BUILD_BUILDID\":\"azure-pipelines-build-id\",\"SYSTEM_JOBID\":\"azure-pipelines-job-id\"}",
837+
"ci.job.url": "https://azure-pipelines-server-uri.com/azure-pipelines-project-id/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id",
838+
"ci.pipeline.id": "azure-pipelines-build-id",
839+
"ci.pipeline.name": "azure-pipelines-name",
840+
"ci.pipeline.number": "azure-pipelines-build-id",
841+
"ci.pipeline.url": "https://azure-pipelines-server-uri.com/azure-pipelines-project-id/_build/results?buildId=azure-pipelines-build-id",
842+
"ci.provider.name": "azurepipelines",
843+
"git.commit.author.email": "azure-pipelines-commit-author-email@datadoghq.com",
844+
"git.commit.author.name": "azure-pipelines-commit-author",
845+
"git.commit.message": "azure-pipelines-commit-message",
846+
"git.repository_url": "ssh://host.xz:port/path/to/repo.git/"
847+
}
848+
],
849+
[
850+
{
851+
"BUILD_BUILDID": "azure-pipelines-build-id",
852+
"BUILD_DEFINITIONNAME": "azure-pipelines-name",
853+
"BUILD_REPOSITORY_URI": "ssh://user:password@1.1.1.1:port/path/to/repo.git/",
854+
"BUILD_REQUESTEDFOREMAIL": "azure-pipelines-commit-author-email@datadoghq.com",
855+
"BUILD_REQUESTEDFORID": "azure-pipelines-commit-author",
856+
"BUILD_SOURCEVERSIONMESSAGE": "azure-pipelines-commit-message",
857+
"SYSTEM_JOBID": "azure-pipelines-job-id",
858+
"SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id",
859+
"SYSTEM_TEAMFOUNDATIONSERVERURI": "https://azure-pipelines-server-uri.com/",
860+
"SYSTEM_TEAMPROJECTID": "azure-pipelines-project-id",
861+
"TF_BUILD": "True"
862+
},
863+
{
864+
"_dd.ci.env_vars": "{\"SYSTEM_TEAMPROJECTID\":\"azure-pipelines-project-id\",\"BUILD_BUILDID\":\"azure-pipelines-build-id\",\"SYSTEM_JOBID\":\"azure-pipelines-job-id\"}",
865+
"ci.job.url": "https://azure-pipelines-server-uri.com/azure-pipelines-project-id/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id",
866+
"ci.pipeline.id": "azure-pipelines-build-id",
867+
"ci.pipeline.name": "azure-pipelines-name",
868+
"ci.pipeline.number": "azure-pipelines-build-id",
869+
"ci.pipeline.url": "https://azure-pipelines-server-uri.com/azure-pipelines-project-id/_build/results?buildId=azure-pipelines-build-id",
870+
"ci.provider.name": "azurepipelines",
871+
"git.commit.author.email": "azure-pipelines-commit-author-email@datadoghq.com",
872+
"git.commit.author.name": "azure-pipelines-commit-author",
873+
"git.commit.message": "azure-pipelines-commit-message",
874+
"git.repository_url": "ssh://1.1.1.1:port/path/to/repo.git/"
875+
}
680876
]
681877
]

0 commit comments

Comments
 (0)