Skip to content

Commit

Permalink
Option to set fixed app id
Browse files Browse the repository at this point in the history
  • Loading branch information
pondzix committed Dec 12, 2024
1 parent 4640977 commit 468295f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/lacework.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 11
- name: Install sbt
uses: sbt/setup-sbt@v1
- name: Get current version
id: ver
run: echo "::set-output name=tag::${GITHUB_REF#refs/tags/}"
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- name: Install sbt
uses: sbt/setup-sbt@v1
- name: Run tests
run: sbt clean scalafmtCheckAll test

Expand All @@ -35,6 +37,8 @@ jobs:
- uses: coursier/cache-action@v6
- name: Set up JDK 11
uses: actions/setup-java@v2
- name: Install sbt
uses: sbt/setup-sbt@v1
with:
java-version: 11
distribution: adopt
Expand Down Expand Up @@ -82,6 +86,8 @@ jobs:
with:
java-version: 11
distribution: adopt
- name: Install sbt
uses: sbt/setup-sbt@v1
- name: Deploy common on Bintray Maven and Maven Central
run: sbt "project core" ci-release
env:
Expand All @@ -102,6 +108,8 @@ jobs:
with:
java-version: 11
distribution: adopt
- name: Install sbt
uses: sbt/setup-sbt@v1
- name: Get current version
id: ver
run: echo "::set-output name=tag::${GITHUB_REF#refs/tags/}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ object SdkEvent {
private def eventFromColPayload(
p: CollectorPayload,
fallbackEid: UUID,
enrichments: Option[Enrichments]
enrichments: Option[Enrichments],
fixedAppId: Option[String]
): List[Event] =
p.payload.map { el =>
val evnt = Some(el.e match {
Expand Down Expand Up @@ -96,7 +97,7 @@ object SdkEvent {
val deprecatedFields = enrichments.flatMap(_.deprecatedFields)

Event(
app_id = el.app.aid,
app_id = fixedAppId.orElse(el.app.aid),
platform = Some(el.app.p),
collector_tstamp = p.context.timestamp,
dvce_created_tstamp = el.dt.flatMap(_.dtm),
Expand Down Expand Up @@ -242,9 +243,10 @@ object SdkEvent {
now: Instant,
frequencies: EventFrequencies,
contexts: Context.ContextsConfig,
generateEnrichments: Boolean = false
generateEnrichments: Boolean = false,
fixedAppId: Option[String] = None
): Gen[List[Event]] =
genPair(eventPerPayloadMin, eventPerPayloadMax, now, frequencies, contexts, generateEnrichments).map(
genPair(eventPerPayloadMin, eventPerPayloadMax, now, frequencies, contexts, generateEnrichments, fixedAppId).map(
_._2
)

Expand All @@ -258,7 +260,8 @@ object SdkEvent {
now: Instant,
frequencies: EventFrequencies,
contexts: Context.ContextsConfig,
generateEnrichments: Boolean
generateEnrichments: Boolean,
fixedAppId: Option[String]
): Gen[(CollectorPayload, List[Event])] =
for {
cp <- CollectorPayload.genDup(
Expand All @@ -274,20 +277,21 @@ object SdkEvent {
)
enrichments <- if (generateEnrichments) Enrichments.gen.map(Some(_)) else Gen.const(None)
eid <- Gen.uuid
} yield (cp, eventFromColPayload(cp, eid, enrichments))
} yield (cp, eventFromColPayload(cp, eid, enrichments, fixedAppId))

def genPair(
eventPerPayloadMin: Int,
eventPerPayloadMax: Int,
now: Instant,
frequencies: EventFrequencies,
contexts: Context.ContextsConfig,
generateEnrichments: Boolean
generateEnrichments: Boolean,
fixedAppId: Option[String]
): Gen[(CollectorPayload, List[Event])] =
for {
cp <- CollectorPayload.gen(eventPerPayloadMin, eventPerPayloadMax, now, frequencies, contexts)
enrichments <- if (generateEnrichments) Enrichments.gen.map(Some(_)) else Gen.const(None)
eid <- Gen.uuid
} yield (cp, eventFromColPayload(cp, eid, enrichments))
} yield (cp, eventFromColPayload(cp, eid, enrichments, fixedAppId))

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ final case class Config(
withEnrichedJson: Boolean,
payloadsPerFile: Int,
duplicates: Option[Config.Duplicates],
fixedAppId: Option[String],
timestamps: Config.Timestamps,
eventFrequencies: EventFrequencies,
contexts: Context.ContextsConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ object Main extends IOApp {
time,
config.eventFrequencies,
config.contexts,
config.generateEnrichments
config.generateEnrichments,
config.fixedAppId
),
rng
),
Expand Down Expand Up @@ -123,7 +124,8 @@ object Main extends IOApp {
time,
config.eventFrequencies,
config.contexts,
config.generateEnrichments
config.generateEnrichments,
config.fixedAppId
),
rng
),
Expand Down

0 comments on commit 468295f

Please sign in to comment.