@@ -164,14 +164,16 @@ PuppetProfileRemediationSaver::PuppetProfileRemediationSaver(QWidget* parentWind
164
164
{}
165
165
166
166
#ifndef SCAP_WORKBENCH_USE_LIBRARY_FOR_RESULT_BASED_REMEDIATION_ROLES_GENERATION
167
- ResultBasedProcessRemediationSaver::ResultBasedProcessRemediationSaver (QWidget* parentWindow, const QByteArray& arfContents,
167
+ ResultBasedProcessRemediationSaver::ResultBasedProcessRemediationSaver (
168
+ QWidget* parentWindow, const QByteArray& arfContents, const QString& tailoringFilePath,
168
169
const QString& saveMessage, const QString& filetypeExtension, const QString& filetypeTemplate, const QString& fixType):
169
170
RemediationSaverBase(parentWindow, saveMessage, filetypeExtension, filetypeTemplate, fixType)
170
171
{
171
172
mArfFile .setAutoRemove (true );
172
173
mArfFile .open ();
173
174
mArfFile .write (arfContents);
174
175
mArfFile .close ();
176
+ tailoring = tailoringFilePath;
175
177
}
176
178
177
179
void ResultBasedProcessRemediationSaver::saveToFile (const QString& filename)
@@ -191,6 +193,11 @@ void ResultBasedProcessRemediationSaver::saveToFile(const QString& filename)
191
193
args.append (" --result-id" );
192
194
args.append (" " );
193
195
196
+ if (!tailoring.isNull ()) {
197
+ args.append (" --tailoring-file" );
198
+ args.append (tailoring.toUtf8 ().constData ());
199
+ }
200
+
194
201
args.append (mArfFile .fileName ());
195
202
196
203
// Launching a process and going through its output is something we do already in OscapScannerLocal::evaluate()
@@ -222,30 +229,32 @@ void ResultBasedProcessRemediationSaver::saveToFile(const QString& filename)
222
229
}
223
230
}
224
231
225
- BashResultRemediationSaver::BashResultRemediationSaver (QWidget* parentWindow, const QByteArray& arfContents):
226
- ResultBasedProcessRemediationSaver(parentWindow, arfContents,
232
+ BashResultRemediationSaver::BashResultRemediationSaver (QWidget* parentWindow, const QByteArray& arfContents, const QString& tailoringFilePath ):
233
+ ResultBasedProcessRemediationSaver(parentWindow, arfContents, tailoringFilePath,
227
234
bashSaveMessage, bashFiletypeExtension, bashFiletypeTemplate, bashFixTemplate)
228
235
{}
229
236
230
- AnsibleResultRemediationSaver::AnsibleResultRemediationSaver (QWidget* parentWindow, const QByteArray& arfContents):
231
- ResultBasedProcessRemediationSaver(parentWindow, arfContents,
237
+ AnsibleResultRemediationSaver::AnsibleResultRemediationSaver (QWidget* parentWindow, const QByteArray& arfContents, const QString& tailoringFilePath ):
238
+ ResultBasedProcessRemediationSaver(parentWindow, arfContents, tailoringFilePath,
232
239
ansibleSaveMessage, ansibleFiletypeExtension, ansibleFiletypeTemplate, ansibleFixType)
233
240
{}
234
241
235
- PuppetResultRemediationSaver::PuppetResultRemediationSaver (QWidget* parentWindow, const QByteArray& arfContents):
236
- ResultBasedProcessRemediationSaver(parentWindow, arfContents,
242
+ PuppetResultRemediationSaver::PuppetResultRemediationSaver (QWidget* parentWindow, const QByteArray& arfContents, const QString& tailoringFilePath ):
243
+ ResultBasedProcessRemediationSaver(parentWindow, arfContents, tailoringFilePath,
237
244
puppetSaveMessage, puppetFiletypeExtension, puppetFiletypeTemplate, puppetFixType)
238
245
{}
239
246
240
247
#else // i.e. SCAP_WORKBENCH_USE_LIBRARY_FOR_RESULT_BASED_REMEDIATION_ROLES_GENERATION is defined
241
- ResultBasedLibraryRemediationSaver::ResultBasedLibraryRemediationSaver (QWidget* parentWindow, const QByteArray& arfContents,
248
+ ResultBasedLibraryRemediationSaver::ResultBasedLibraryRemediationSaver (
249
+ QWidget* parentWindow, const QByteArray& arfContents, const QString& tailoringFilePath,
242
250
const QString& saveMessage, const QString& filetypeExtension, const QString& filetypeTemplate, const QString& fixType):
243
251
RemediationSaverBase(parentWindow, saveMessage, filetypeExtension, filetypeTemplate, fixType)
244
252
{
245
253
mArfFile .setAutoRemove (true );
246
254
mArfFile .open ();
247
255
mArfFile .write (arfContents);
248
256
mArfFile .close ();
257
+ tailoring = tailoringFilePath;
249
258
}
250
259
251
260
void ResultBasedLibraryRemediationSaver::saveToFile (const QString& filename)
@@ -282,6 +291,9 @@ void ResultBasedLibraryRemediationSaver::saveToFile(const QString& filename)
282
291
283
292
if (session == NULL )
284
293
throw std::runtime_error (" Couldn't get XCCDF session from the report source" );
294
+ if (!tailoring.isNull ()) {
295
+ xccdf_session_set_user_tailoring_file (session, tailoring.toUtf8 ().constData ());
296
+ }
285
297
286
298
xccdf_session_set_loading_flags (session, XCCDF_SESSION_LOAD_XCCDF);
287
299
if (xccdf_session_load (session) != 0 )
@@ -316,18 +328,18 @@ void ResultBasedLibraryRemediationSaver::saveToFile(const QString& filename)
316
328
}
317
329
}
318
330
319
- BashResultRemediationSaver::BashResultRemediationSaver (QWidget* parentWindow, const QByteArray& arfContents):
320
- ResultBasedLibraryRemediationSaver(parentWindow, arfContents,
331
+ BashResultRemediationSaver::BashResultRemediationSaver (QWidget* parentWindow, const QByteArray& arfContents, const QString& tailoringFilePath ):
332
+ ResultBasedLibraryRemediationSaver(parentWindow, arfContents, tailoringFilePath,
321
333
bashSaveMessage, bashFiletypeExtension, bashFiletypeTemplate, bashFixTemplate)
322
334
{}
323
335
324
- AnsibleResultRemediationSaver::AnsibleResultRemediationSaver (QWidget* parentWindow, const QByteArray& arfContents):
325
- ResultBasedLibraryRemediationSaver(parentWindow, arfContents,
336
+ AnsibleResultRemediationSaver::AnsibleResultRemediationSaver (QWidget* parentWindow, const QByteArray& arfContents, const QString& tailoringFilePath ):
337
+ ResultBasedLibraryRemediationSaver(parentWindow, arfContents, tailoringFilePath,
326
338
ansibleSaveMessage, ansibleFiletypeExtension, ansibleFiletypeTemplate, ansibleFixType)
327
339
{}
328
340
329
- PuppetResultRemediationSaver::PuppetResultRemediationSaver (QWidget* parentWindow, const QByteArray& arfContents):
330
- ResultBasedLibraryRemediationSaver(parentWindow, arfContents,
341
+ PuppetResultRemediationSaver::PuppetResultRemediationSaver (QWidget* parentWindow, const QByteArray& arfContents, const QString& tailoringFilePath ):
342
+ ResultBasedLibraryRemediationSaver(parentWindow, arfContents, tailoringFilePath,
331
343
puppetSaveMessage, puppetFiletypeExtension, puppetFiletypeTemplate, puppetFixType)
332
344
{}
333
345
0 commit comments