Skip to content

v0.4.7 #53

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

Merged
merged 7 commits into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
kotlin.code.style=official

projectVersion=0.4.6
projectVersion=0.4.7

kotlinVersion=1.6.10
vertxVersion=4.2.6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ enum class MetricType {
return (values().find { it.name == name }
?: when (name) {
"endpoint_cpm" -> Throughput_Average
"endpoint_avg" -> ResponseTime_Average
"endpoint_avg", "endpoint_resp_time" -> ResponseTime_Average
"endpoint_sla" -> ServiceLevelAgreement_Average
"endpoint_percentile" -> ResponseTime_99Percentile
else -> throw UnsupportedOperationException(name)
Expand Down
16 changes: 14 additions & 2 deletions src/commonMain/kotlin/spp.protocol/platform/auth/DataRedaction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,17 @@ package spp.protocol.platform.auth

data class DataRedaction(
val id: String,
val redactionPattern: String
)
val type: RedactionType,
val lookup: String,
val replacement: String
) {
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other == null || this::class != other::class) return false
other as DataRedaction
if (id != other.id) return false
return true
}

override fun hashCode(): Int = id.hashCode()
}
26 changes: 26 additions & 0 deletions src/commonMain/kotlin/spp.protocol/platform/auth/RedactionType.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Source++, the open-source live coding platform.
* Copyright (C) 2022 CodeBrig, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package spp.protocol.platform.auth

/**
* The type of redaction lookup to perform.
*/
enum class RedactionType {
IDENTIFIER_MATCH,
VALUE_REGEX
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ enum class RolePermission(val manager: Boolean, val commandType: CommandType) {
//instrument access
GET_ACCESS_PERMISSIONS(true, LIVE_SERVICE),
GET_DATA_REDACTIONS(true, LIVE_SERVICE),
ADD_DATA_REDACTION(true, LIVE_SERVICE),
REMOVE_DATA_REDACTION(true, LIVE_SERVICE),
UPDATE_DATA_REDACTION(true, LIVE_SERVICE),
ADD_ACCESS_PERMISSION(true, LIVE_SERVICE),
REMOVE_ACCESS_PERMISSION(true, LIVE_SERVICE),

Expand Down
17 changes: 17 additions & 0 deletions src/jvmMain/kotlin/spp/protocol/marshall/ProtocolMarshaller.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ import spp.protocol.instrument.event.LiveBreakpointHit
import spp.protocol.instrument.event.LiveInstrumentRemoved
import spp.protocol.instrument.event.LiveLogHit
import spp.protocol.instrument.variable.LiveVariable
import spp.protocol.platform.auth.DataRedaction
import spp.protocol.platform.auth.RedactionType
import spp.protocol.platform.developer.SelfInfo
import spp.protocol.platform.general.Service
import spp.protocol.platform.status.ActiveInstance
Expand Down Expand Up @@ -407,4 +409,19 @@ object ProtocolMarshaller {
value.getJsonArray("arguments").list.map { it.toString() }
)
}

@JvmStatic
fun serializeDataRedaction(value: DataRedaction): JsonObject {
return JsonObject(Json.encode(value))
}

@JvmStatic
fun deserializeDataRedaction(value: JsonObject): DataRedaction {
return DataRedaction(
value.getString("id"),
RedactionType.valueOf(value.getString("type")),
value.getString("lookup"),
value.getString("replacement")
)
}
}