Skip to content

Commit 74e1e6f

Browse files
authored
Reduce delay to make build faster. Fix unsafe json serialization. (#2879)
1 parent d7c71ed commit 74e1e6f

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/app/Fake.Core.Process/Process.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Fake.Core
1+
namespace Fake.Core
22

33
open System
44
open System.Diagnostics
@@ -815,7 +815,7 @@ module Process =
815815

816816
while DateTime.Now <= endTime && not (getAllByName name |> Seq.isEmpty) do
817817
Trace.tracefn "Waiting for %s to stop (Timeout: %A)" name endTime
818-
Thread.Sleep 1000
818+
Thread.Sleep 100
819819

820820
if not (getAllByName name |> Seq.isEmpty) then
821821
failwithf "The process %s has not stopped (check the logs for errors)" name

src/app/Fake.Core.Vault/Vault.fs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ module Vault =
1616

1717
let private aesCtrTransform (key: byte[], salt: byte[], inputStream: Stream, outputStream: Stream) =
1818
// https://stackoverflow.com/a/51188472/1269722
19-
let aes = new AesManaged(Mode = CipherMode.ECB, Padding = PaddingMode.None)
19+
// Use Aes.Create() instead of deprecated AesManaged
20+
use aes = Aes.Create(Mode = CipherMode.ECB, Padding = PaddingMode.None)
2021
let blockSize = aes.BlockSize / 8
2122

2223
if (salt.Length <> blockSize) then
@@ -187,12 +188,14 @@ module Vault =
187188
Variables = Map.empty }
188189

189190
/// <summary>
190-
/// Read in a vault from a given json string, make sure to delete the source of the json after using this API
191+
/// Read a vault from a JSON string
191192
/// </summary>
192193
///
193194
/// <param name="str">The JSON string of the vault to read</param>
194195
let fromJson str =
195-
let vars = JsonConvert.DeserializeObject<Variables>(str)
196+
// Secure JSON deserialization: disable type name handling to prevent deserialization attacks
197+
let settings = JsonSerializerSettings(TypeNameHandling = TypeNameHandling.None)
198+
let vars = JsonConvert.DeserializeObject<Variables>(str, settings)
196199
fromEncryptedVariables { KeyFile = vars.keyFile; Iv = vars.iv } vars.values
197200

198201
/// <summary>

0 commit comments

Comments
 (0)