[OVAL DEVELOPER] Oval feature recommendation string 'replace' function

Vanderpol, Jack R CIV USN SPAWARSYSCEN LANT SC (US) jack.r.vanderpol.civ at mail.mil
Tue Jul 24 15:28:33 EDT 2018


I'm writing some content, and obtaining data from textfilecontent54 subexpression, and it has some undesirable data that I'd like to quickly replace with the "correct" data, before using in another object.   I was thinking that I might be able to replicate the functionality of a 'replace' with a combination of a split and concat, but after looking at other samples of concat, I don't think I'm going to end up with a single string.



If anyone has any methods in OVAL to replace a substring and make a new string I'd appreciate it.   I'm hoping to be flamed, that I missed something trivial, so feel free to blast away.



I'm parsing the deployment.config file in Java 8 to see what the path is to the https://protect-us.mimecast.com/s/lhvZCXDXgmCVPRmU66CfK?domain=deployment.properties file is, but they intentionally use forward slashes instead of backslashes on Windows.  While using forward slashes in Windows filepaths may work, I didn't wasn't to assume it would work as expected in all SCAP tools, as a valid Windows path.



Input:



C:/Windows/Sun/Java/Deployment/deployment.properties



Desired Output:



C:\Windows\Sun\Java\Deployment\deployment.properties



If I split my original string with /, I suspect I'll get back a variable with



C:

Windows

Sun

Java

Deployment

https://protect-us.mimecast.com/s/lhvZCXDXgmCVPRmU66CfK?domain=deployment.properties



If I then concat each with \ I'll end up with

C:\

Windows\

Sun\

Java\

Deployment\

https://protect-us.mimecast.com/s/7ZZ8CYEYjoSEWq5sGbzOQ?domain=deployment.properties (which I don't want either...)



Then I'm unsure if or how to glue my multiple element variable back to a single string.





So, just checking to see if I'm offtrack or if a regex replace substring function would be useful in OVAL?





Thanks,

Jack Vander Pol


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cisecurity.org/pipermail/oval_developer_lists.cisecurity.org/attachments/20180724/1c7583cd/attachment.html>


More information about the OVAL_Developer mailing list