Skip to content

Commit

Permalink
Merge pull request #184 from RuntimeTools/4.1
Browse files Browse the repository at this point in the history
Update to Swift 4.1 and Kitura 2.3
  • Loading branch information
sjanuary committed Apr 18, 2018
2 parents 84d706a + 7814944 commit bd9129d
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .swift-version
@@ -1 +1 @@
4.0.3
4.1
10 changes: 9 additions & 1 deletion .travis.yml
@@ -1,4 +1,4 @@
# Travis CI build file for Kitura sample app.
# Travis CI build file for SwiftMetrics.
# Kitura runs on OS X and Linux (Ubuntu).
# See the following URLs for further details on Travis CI
# https://docs.travis-ci.com/user/customizing-the-build/
Expand All @@ -13,12 +13,20 @@ branches:

matrix:
include:
- os: linux
dist: trusty
sudo: required
env: SWIFT_SNAPSHOT=4.0.3
- os: linux
dist: trusty
sudo: required
- os: osx
osx_image: xcode9.2
sudo: required
env: SWIFT_SNAPSHOT=4.0.3
- os: osx
osx_image: xcode9.3
sudo: required

before_install:
- git clone https://github.com/IBM-Swift/Package-Builder.git
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Expand Up @@ -33,8 +33,8 @@ let package = Package(
.executable(name: "SwiftMetricsCommonSample", targets: ["SwiftMetricsCommonSample"]),
],
dependencies: [
.package(url: "https://github.com/IBM-Swift/Kitura.git", from: "2.1.0"),
.package(url: "https://github.com/IBM-Swift/Kitura-WebSocket.git", from: "1.0.0"),
.package(url: "https://github.com/IBM-Swift/Kitura.git", from: "2.3.0"),
.package(url: "https://github.com/IBM-Swift/Kitura-WebSocket.git", from: "2.0.0"),
.package(url: "https://github.com/IBM-Swift/SwiftyRequest.git", from: "1.0.0"),
.package(url: "https://github.com/IBM-Swift/Swift-cfenv.git", from: "6.0.0"),
.package(url: "https://github.com/IBM-Swift/SwiftyJSON.git", from: "17.0.0"),
Expand Down
8 changes: 7 additions & 1 deletion README.md
Expand Up @@ -32,7 +32,13 @@ Application Metrics for Swift provides the following built-in data collection so

The Application Metrics for Swift agent supports the following runtime environments:

* **Swift v3 GA** on:
* **Swift v4.1 GA** on:
* 64-bit runtime on Linux (Ubuntu 14.04, 16.04)
* 64-bit runtime on macOS (x64)
* **Swift v4 GA** on:
* 64-bit runtime on Linux (Ubuntu 14.04, 16.04)
* 64-bit runtime on macOS (x64)
* **Swift v3.1.1 GA** using SwiftMetrics version 1.2.5 on:
* 64-bit runtime on Linux (Ubuntu 14.04, 15.10)
* 64-bit runtime on macOS (x64)

Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftBAMDC/SwiftDataCollector.swift
Expand Up @@ -455,7 +455,7 @@ public func getISOTimeStamp(time : Date) -> String {
let formatter = DateFormatter()

formatter.dateFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'SSS'Z'"
formatter.timeZone = TimeZone(abbreviation: "UTC") as TimeZone!
formatter.timeZone = TimeZone(abbreviation: "UTC")

return formatter.string(from: time)
}
Expand Down
68 changes: 38 additions & 30 deletions Sources/SwiftBAMDC/SwiftMetricsBAMConfig.swift
Expand Up @@ -616,56 +616,64 @@ public class TokenUtil {
let i = cipher_init(key: key)

if let ky = i["key"], let vl = i["iv"] {
let c = Cryptor(operation: .encrypt,
algorithm: .aes,
options: .pkcs7Padding,
key: ky,
iv: vl)
do {
let c = try Cryptor(operation: .encrypt,
algorithm: .aes,
options: .pkcs7Padding,
key: ky,
iv: vl)

let b = c.update(string: value)?.final()
let b = c.update(string: value)?.final()

if let bv = b {
let d = Data(bytes: bv, count: bv.count).base64EncodedData()
if let bv = b {
let d = Data(bytes: bv, count: bv.count).base64EncodedData()

let s = String(data: d, encoding: String.Encoding.utf8)
let s = String(data: d, encoding: String.Encoding.utf8)

if let sv = s {
Log.debug("[SwiftMetricsBAMConfig] Encrypt successful: \(key) val: \(sv)")
return sv
if let sv = s {
Log.debug("[SwiftMetricsBAMConfig] Encrypt successful: \(key) val: \(sv)")
return sv
}
}
} catch {
// do nothing
}
}

Log.debug("[SwiftMetricsBAMConfig] Encrypt failed: \(key)")
Log.error("[SwiftMetricsBAMConfig] Encrypt failed: \(key)")
return ""
}

public static func unobfuscate(key: String, value: String) -> String {
let i = cipher_init(key: key)

if let ky = i["key"], let vl = i["iv"] {
let c = Cryptor(operation: .decrypt,
algorithm: .aes,
options: .pkcs7Padding,
key: ky,
iv: vl)
let b = Data(base64Encoded: value)
if let bv = b {
let p = c.update(data: bv)?.final()

if let pv = p {
let d = Data(bytes: pv, count: pv.count)
let s = String(data: d, encoding: String.Encoding.utf8)

if let sv = s {
Log.debug("[SwiftMetricsBAMConfig] Decrypt successful: \(key) val: \(value)")
return sv
do {
let c = try Cryptor(operation: .decrypt,
algorithm: .aes,
options: .pkcs7Padding,
key: ky,
iv: vl)
let b = Data(base64Encoded: value)
if let bv = b {
let p = c.update(data: bv)?.final()

if let pv = p {
let d = Data(bytes: pv, count: pv.count)
let s = String(data: d, encoding: String.Encoding.utf8)

if let sv = s {
Log.debug("[SwiftMetricsBAMConfig] Decrypt successful: \(key) val: \(value)")
return sv
}
}
}
} catch {
// do nothing
}
}

Log.debug("[SwiftMetricsBAMConfig] Decrypt failed: \(key) val: \(value)")
Log.error("[SwiftMetricsBAMConfig] Decrypt failed: \(key) val: \(value)")

return ""
}
Expand Down

0 comments on commit bd9129d

Please sign in to comment.