File tree 4 files changed +19
-18
lines changed
4 files changed +19
-18
lines changed Original file line number Diff line number Diff line change 9
9
10
10
from ..plugins .core import initialize
11
11
from ..plugins .high_entropy_strings import HighEntropyStringsPlugin
12
+ from .baseline import format_baseline_for_output
12
13
from .baseline import merge_results
13
14
from .bidirectional_iterator import BidirectionalIterator
14
15
from .color import BashColor
@@ -201,12 +202,7 @@ def _handle_user_decision(decision, secret):
201
202
202
203
def _save_baseline_to_file (filename , data ): # pragma: no cover
203
204
with open (filename , 'w' ) as f :
204
- f .write (json .dumps (
205
- data ,
206
- indent = 2 ,
207
- sort_keys = True ,
208
- separators = (',' , ': ' ),
209
- ))
205
+ f .write (format_baseline_for_output (data ))
210
206
211
207
212
208
def _get_secret_with_context (
Original file line number Diff line number Diff line change 1
1
from __future__ import absolute_import
2
2
3
+ import json
3
4
import os
4
5
import re
5
6
import subprocess
@@ -229,6 +230,19 @@ def merge_results(old_results, new_results):
229
230
return new_results
230
231
231
232
233
+ def format_baseline_for_output (baseline ):
234
+ """
235
+ :type baseline: dict
236
+ :rtype: str
237
+ """
238
+ return json .dumps (
239
+ baseline ,
240
+ indent = 2 ,
241
+ sort_keys = True ,
242
+ separators = (',' , ': ' ),
243
+ )
244
+
245
+
232
246
def _get_git_tracked_files (rootdir = '.' ):
233
247
"""Parsing .gitignore rules is hard.
234
248
Original file line number Diff line number Diff line change @@ -38,11 +38,8 @@ def main(argv=None):
38
38
_scan_string (line , plugins )
39
39
40
40
else :
41
- output = json . dumps (
41
+ output = baseline . format_baseline_for_output (
42
42
_perform_scan (args , plugins ),
43
- indent = 2 ,
44
- sort_keys = True ,
45
- separators = (',' , ': ' ),
46
43
)
47
44
48
45
if args .import_filename :
Original file line number Diff line number Diff line change 6
6
import textwrap
7
7
8
8
from detect_secrets import VERSION
9
+ from detect_secrets .core .baseline import format_baseline_for_output
9
10
from detect_secrets .core .baseline import get_secrets_not_in_baseline
10
11
from detect_secrets .core .baseline import update_baseline_with_removed_secrets
11
12
from detect_secrets .core .log import get_logger
@@ -72,14 +73,7 @@ def main(argv=None):
72
73
def _write_to_baseline_file (filename , payload ): # pragma: no cover
73
74
"""Breaking this function up for mockability."""
74
75
with open (filename , 'w' ) as f :
75
- f .write (
76
- json .dumps (
77
- payload ,
78
- indent = 2 ,
79
- sort_keys = True ,
80
- separators = (',' , ': ' ),
81
- ),
82
- )
76
+ f .write (format_baseline_for_output (payload ))
83
77
84
78
85
79
def get_baseline (baseline_filename ):
You can’t perform that action at this time.
0 commit comments