Skip to content

Commit

Permalink
feat: add jni references to configuration screen
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Bretting <[email protected]>
  • Loading branch information
luca-dot-sh committed Dec 12, 2024
1 parent c211d0e commit 0ad08f0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.lifecycle.viewModelScope
import de.amosproj3.ziofa.api.configuration.BackendConfigurationAccess
import de.amosproj3.ziofa.api.configuration.ConfigurationUpdate
import de.amosproj3.ziofa.api.configuration.LocalConfigurationAccess
import de.amosproj3.ziofa.client.JniReferencesConfig
import de.amosproj3.ziofa.client.SysSendmsgConfig
import de.amosproj3.ziofa.client.UprobeConfig
import de.amosproj3.ziofa.client.VfsWriteConfig
Expand Down Expand Up @@ -82,6 +83,13 @@ class ConfigurationViewModel(
)
}

is BackendFeatureOptions.JniReferencesOption->{
localConfigurationAccess.changeFeatureConfiguration(
enable = active,
jniReferencesFeature = JniReferencesConfig(pids)
)
}

else -> throw NotImplementedError("NO SUPPORT YET")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ fun SectionTitleRow(title: String) {
Row(horizontalArrangement = Arrangement.Center, modifier = Modifier.padding(bottom = 10.dp)) {
Text(title, fontWeight = FontWeight.Bold)
}
HorizontalDivider(thickness = 5.dp)
HorizontalDivider(thickness = 3.dp)
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ sealed class BackendFeatureOptions(val featureName: String, val active: Boolean)
data class SendMessageOption(val enabled: Boolean, val pids: Set<UInt>) :
BackendFeatureOptions("Unix Domain Socket Analysis", enabled)

data class JniReferencesOption(val enabled: Boolean, val pids: Set<UInt>) :
BackendFeatureOptions("Local & Global Indirect JNI References", enabled)


data class UprobeOption(
val method: String,
val enabled: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ fun VfsWriteConfig?.updatePIDs(
val config = this ?: VfsWriteConfig(mapOf())
return config.copy(
entries =
config.entries.entries.plus(pidsToAdd).minus(pidsToRemove).associate {
it.key to it.value
}
config.entries.entries.plus(pidsToAdd).minus(pidsToRemove).associate {
it.key to it.value
}
)
}

Expand All @@ -31,9 +31,9 @@ fun SysSendmsgConfig?.updatePIDs(
val config = this ?: SysSendmsgConfig(mapOf())
return config.copy(
entries =
config.entries.entries.plus(pidsToAdd).minus(pidsToRemove).associate {
it.key to it.value
}
config.entries.entries.plus(pidsToAdd).minus(pidsToRemove).associate {
it.key to it.value
}
)
}

Expand Down Expand Up @@ -77,6 +77,15 @@ fun ConfigurationUpdate.Valid.toUIOptionsForPids(
} ?: BackendFeatureOptions.SendMessageOption(enabled = false, pids = setOf())
)

options.add(
this.configuration.jniReferences?.let {
BackendFeatureOptions.JniReferencesOption(
enabled = it.pids.anyPidsEnabled(relevantPids),
pids = it.pids.toSet()
)
} ?: BackendFeatureOptions.JniReferencesOption(enabled = false, pids = setOf())
)

this.configuration.uprobes
.filter { it.pid == null || relevantPids.contains(it.pid!!.toUInt()) }
.forEach { uprobeConfig ->
Expand Down

0 comments on commit 0ad08f0

Please sign in to comment.