Skip to content
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

Logging and autofill improvements #30

Merged
merged 3 commits into from
Nov 9, 2023
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 .fvm/fvm_config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"flutterSdkVersion": "3.13.2",
"flutterSdkVersion": "3.13.9",
"flavors": {}
}
7 changes: 5 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ android {
defaultConfig {
applicationId "com.keevault.keevault"
applicationIdSuffix idSuffix
minSdkVersion 26
targetSdkVersion 33
minSdkVersion 29
targetSdk 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
resValue "string", "app_name", "Kee Vault" + nameSuffix
Expand Down Expand Up @@ -148,5 +148,8 @@ flutter {

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'org.tinylog:tinylog-api:2.6.2'
implementation 'org.tinylog:tinylog-impl:2.6.2'
implementation 'org.tinylog:slf4j-tinylog:2.6.2'
androidTestUtil "androidx.test:orchestrator:1.4.2"
}
10 changes: 9 additions & 1 deletion android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
-keep class androidx.lifecycle.DefaultLifecycleObserver
-keep class androidx.lifecycle.DefaultLifecycleObserver
-keepnames interface org.tinylog.**
-keepnames class * implements org.tinylog.**
-keepclassmembers class * implements org.tinylog.** { <init>(...); }

-dontwarn dalvik.system.VMStack
-dontwarn java.lang.**
-dontwarn javax.naming.**
-dontwarn sun.reflect.Reflection
3 changes: 3 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
<meta-data
android:name="com.keevault.flutter_autofill_service.match_header_drawable_name"
android:value="ic_v_light_key_24dp" />
<meta-data
android:name="com.keevault.flutter_autofill_service.pinned_drawable_name"
android:value="ic_v_light_key_24dp" />

<service
android:name="com.keevault.flutter_autofill_service.FlutterAutofillService"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ import android.content.Intent
import androidx.annotation.NonNull
import io.flutter.embedding.android.FlutterFragmentActivity
import io.flutter.embedding.engine.FlutterEngine
import android.os.Bundle

class AutofillActivity: FlutterFragmentActivity() {
class AutofillActivity(): FlutterFragmentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
System.setProperty("logs.folder", filesDir.absolutePath + "/logs");

super.onCreate(savedInstanceState)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ import android.content.Intent
import androidx.annotation.NonNull
import io.flutter.embedding.android.FlutterFragmentActivity
import io.flutter.embedding.engine.FlutterEngine
import android.os.Bundle

class MainActivity: FlutterFragmentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
System.setProperty("logs.folder", filesDir.absolutePath + "/logs");

super.onCreate(savedInstanceState)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.keevault.flutter_autofill_service.DynamicLevelLoggingProvider
14 changes: 14 additions & 0 deletions android/app/src/main/resources/tinylog.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
provider = dynamic level
level = trace

writer1 = logcat

writer2 = rolling file
writer2.file = #{logs.folder}/autofill-{pid}-log-{count}.txt
writer2.charset = UTF-8
writer2.backups = 30
writer2.buffered = true
writer2.policies = startup, size: 1mb, dynamic
writer2.format = {date: yyyy-MM-dd HH:mm:ss.SSS} [{thread-id}_{thread}] {class}.{method}():{line}\n{level}: {message}

writingthread = true
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.8.0'
ext.kotlin_version = '1.8.22'
repositories {
google()
mavenCentral()
Expand Down
6 changes: 3 additions & 3 deletions ios/KdbxSwift/Sources/KdbxSwift/DatabaseFileManager.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import os.log
import Logging

public class DatabaseFileManager {
public enum Error {
Expand Down Expand Up @@ -68,7 +68,7 @@ public class DatabaseFileManager {
Logger.mainLog.debug("Loaded main KDBX")

} catch {
Logger.mainLog.error("Failed to read current KDBX file [message: \(error.localizedDescription, privacy: .public)]")
Logger.mainLog.error("Failed to read current KDBX file", metadata: ["public:message": "\(error.localizedDescription)"])
Logger.fatalError("couldn't read KDBX file")
}
}
Expand Down Expand Up @@ -107,7 +107,7 @@ public class DatabaseFileManager {
let fileData = try targetDatabase.save()
try fileData.write(to: kdbxAutofillURL, options: .atomic)
} catch {
Logger.mainLog.error("Failed to write autofill KDBX file [message: \(error.localizedDescription, privacy: .public)]")
Logger.mainLog.error("Failed to write autofill KDBX file", metadata: ["public:message": "\(error.localizedDescription)"])
}
}
}
2 changes: 1 addition & 1 deletion ios/KdbxSwift/Sources/KdbxSwift/base32/Base32.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
// THE SOFTWARE.

import Foundation
import os.log
import Logging

// https://tools.ietf.org/html/rfc4648

Expand Down
4 changes: 2 additions & 2 deletions ios/KdbxSwift/Sources/KdbxSwift/crypto/CryptoManager.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation
import CommonCrypto.CommonHMAC
import os.log
import Logging

public enum CryptoError: Error {
case invalidKDFParam(kdfName: String, paramName: String)
Expand Down Expand Up @@ -37,7 +37,7 @@ public final class CryptoManager {
return SecRandomCopyBytes(kSecRandomDefault, outBytes.count, &outBytes)
}
if status != errSecSuccess {
Logger.mainLog.warning("Failed to generate random bytes [count: \(count, privacy: .public), status: \(status, privacy: .public)]")
Logger.mainLog.warning("Failed to generate random bytes", metadata: ["public:count": "\(count)", "public:status": "\(status)"])
throw CryptoError.rngError(code: Int(status))
}
return output
Expand Down
3 changes: 2 additions & 1 deletion ios/KdbxSwift/Sources/KdbxSwift/db/Database.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Foundation
import os.log
import Logging


public struct SearchQuery {
public let includeSubgroups: Bool
Expand Down
2 changes: 1 addition & 1 deletion ios/KdbxSwift/Sources/KdbxSwift/db/DatabaseItem.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os.log
import Logging

open class DatabaseItem {
public enum TouchMode {
Expand Down
2 changes: 1 addition & 1 deletion ios/KdbxSwift/Sources/KdbxSwift/db/Entry.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import os.log
import Logging

public class EntryField: Eraseable {
public static let title = "Title"
Expand Down
4 changes: 2 additions & 2 deletions ios/KdbxSwift/Sources/KdbxSwift/db/EntryFieldReference.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import os.log
import Logging

public class EntryFieldReference {
public enum Status {
Expand Down Expand Up @@ -226,7 +226,7 @@ public class EntryFieldReference {
_uuid = UUID(uuidString: String(value))
}
guard let uuid = _uuid else {
Logger.mainLog.debug("Malformed UUID: \(value)")
Logger.mainLog.debug("Malformed UUID", metadata: ["value": "\(value)"])
return nil
}
result = entries.first(where: { $0.uuid == uuid })
Expand Down
2 changes: 1 addition & 1 deletion ios/KdbxSwift/Sources/KdbxSwift/db/Group.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import os.log
import Logging

public class Group: DatabaseItem, Eraseable {
public static let defaultIconID = IconID.folder
Expand Down
2 changes: 1 addition & 1 deletion ios/KdbxSwift/Sources/KdbxSwift/db/KeyHelper.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import os.log
import Logging

public class KeyHelper {
public static let compositeKeyLength = 32
Expand Down
2 changes: 1 addition & 1 deletion ios/KdbxSwift/Sources/KdbxSwift/db/cipher/DataCipher.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import os.log
import Logging

protocol DataCipher: AnyObject {
var uuid: UUID { get }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import os.log
import Logging

final class DataCipherFactory {
public static let instance = DataCipherFactory()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import os.log
import Logging

internal enum ProtectedStreamAlgorithm: UInt32 {
case Null = 0
Expand Down
2 changes: 1 addition & 1 deletion ios/KdbxSwift/Sources/KdbxSwift/db/kdf/Argon2KDF.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import os.log
import Logging

class AbstractArgon2KDF {
public static let saltParam = "S"
Expand Down
2 changes: 1 addition & 1 deletion ios/KdbxSwift/Sources/KdbxSwift/db/kdf/KDFParams.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import os.log
import Logging

final class KDFParams: VarDict {
public static let uuidParam = "$UUID"
Expand Down
4 changes: 2 additions & 2 deletions ios/KdbxSwift/Sources/KdbxSwift/db/kp2/Attachment2.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import os.log
import Logging

public class Attachment2: Attachment {
public var id: Int
Expand Down Expand Up @@ -56,7 +56,7 @@ public class Attachment2: Attachment {
)
}
default:
Logger.mainLog.error("Unexpected XML tag in Entry/Binary: \(tag.name)")
Logger.mainLog.error("Unexpected XML tag in Entry/Binary", metadata: ["name": "\(tag.name)"])
throw Xml2.ParsingError.unexpectedTag(actual: tag.name, expected: "Entry/Binary/*")
}
}
Expand Down
2 changes: 1 addition & 1 deletion ios/KdbxSwift/Sources/KdbxSwift/db/kp2/Binary2.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import os.log
import Logging

public class Binary2: Eraseable {
public typealias ID = Int
Expand Down
10 changes: 5 additions & 5 deletions ios/KdbxSwift/Sources/KdbxSwift/db/kp2/CustomData2.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import os.log
import Logging

public class CustomData2: Eraseable {

Expand Down Expand Up @@ -71,7 +71,7 @@ public class CustomData2: Eraseable {
)
Logger.mainLog.trace("Item loaded OK")
default:
Logger.mainLog.error("Unexpected XML tag in CustomData: \(tag.name)")
Logger.mainLog.error("Unexpected XML tag in CustomData", metadata: ["name": "\(tag.name)"])
throw Xml2.ParsingError.unexpectedTag(
actual: tag.name,
expected: xmlParentName + "/CustomData/*")
Expand All @@ -98,20 +98,20 @@ public class CustomData2: Eraseable {
case Xml2.lastModificationTime:
optionalTimestamp = timeParser.xmlStringToDate(tag.value)
default:
Logger.mainLog.error("Unexpected XML tag in CustomData/Item: \(tag.name)")
Logger.mainLog.error("Unexpected XML tag in CustomData/Item", metadata: ["name": "\(tag.name)"])
throw Xml2.ParsingError.unexpectedTag(
actual: tag.name,
expected: xmlParentName + "/CustomData/Item/*")
}
}
guard let _key = key else {
Logger.mainLog.error("Missing \(xmlParentName)/CustomData/Item/Key")
Logger.mainLog.error("Missing parent/CustomData/Item/Key", metadata: ["parent": "\(xmlParentName)"])
throw Xml2.ParsingError.malformedValue(
tag: xmlParentName + "/CustomData/Item/Key",
value: nil)
}
guard let _value = value else {
Logger.mainLog.error("Missing \(xmlParentName)/CustomData/Item/Value")
Logger.mainLog.error("Missing parent/CustomData/Item/Value", metadata: ["parent": "\(xmlParentName)"])
throw Xml2.ParsingError.malformedValue(
tag: xmlParentName + "/CustomData/Item/Value",
value: nil)
Expand Down
4 changes: 2 additions & 2 deletions ios/KdbxSwift/Sources/KdbxSwift/db/kp2/CustomIcon2.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import os.log
import Logging

public class CustomIcon2: Eraseable {
public private(set) var uuid: UUID
Expand Down Expand Up @@ -73,7 +73,7 @@ public class CustomIcon2: Eraseable {
case Xml2.lastModificationTime:
xmlLastModificationTime = timeParser.xmlStringToDate(tag.value)
default:
Logger.mainLog.error("Unexpected XML tag in CustomIcon: \(tag.name)")
Logger.mainLog.error("Unexpected XML tag in CustomIcon", metadata: ["name": "\(tag.name)"])
throw Xml2.ParsingError.unexpectedTag(actual: tag.name, expected: "CustomIcon/*")
}
}
Expand Down
Loading