oval_developer@lists.cisecurity.org

A list for people interested in developing the OVAL language.

View all threads

Oval feature recommendation string 'replace' function

VJ
Vanderpol, Jack R CIV USN SPAWARSYSCEN LANT SC (US)
Tue, Jul 24, 2018 7:28 PM

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

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
DS
David Solin
Tue, Jul 24, 2018 10:54 PM

Hi Jack,

I was going to suggest: "why not use the ReplaceFunctionType" … but then I discovered there simply is no such thing!  I feel like someone proposed this before, but perhaps I only dreamed it.

I can’t think of any other way to achieve what you want to do.  Do you want to write up a proposal for a new function?

Best regards,
—David Solin

On Jul 24, 2018, at 2:28 PM, Vanderpol, Jack R CIV USN SPAWARSYSCEN LANT SC (US) jack.r.vanderpol.civ@mail.mil wrote:

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/8BGsCo2nMptjAK4TVWJtg?domain=deployment.properties https://protect-us.mimecast.com/s/qu2hCmZ0KltBVR2hG17Tz?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/8BGsCo2nMptjAK4TVWJtg?domain=deployment.properties https://protect-us.mimecast.com/s/qu2hCmZ0KltBVR2hG17Tz?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/PLLLCpYoNrU1gxDUGZA9z?domain=deployment.properties https://protect-us.mimecast.com/s/oJtnCn5mLntA465tJuI58?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


OVAL_Developer mailing list
OVAL_Developer@lists.cisecurity.org mailto:OVAL_Developer@lists.cisecurity.org
http://lists.cisecurity.org/mailman/listinfo/oval_developer_lists.cisecurity.org http://lists.cisecurity.org/mailman/listinfo/oval_developer_lists.cisecurity.org

Hi Jack, I was going to suggest: "why not use the ReplaceFunctionType" … but then I discovered there simply is no such thing! I feel like someone proposed this before, but perhaps I only dreamed it. I can’t think of any other way to achieve what you want to do. Do you want to write up a proposal for a new function? Best regards, —David Solin > On Jul 24, 2018, at 2:28 PM, Vanderpol, Jack R CIV USN SPAWARSYSCEN LANT SC (US) <jack.r.vanderpol.civ@mail.mil> wrote: > > 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/8BGsCo2nMptjAK4TVWJtg?domain=deployment.properties <https://protect-us.mimecast.com/s/qu2hCmZ0KltBVR2hG17Tz?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/8BGsCo2nMptjAK4TVWJtg?domain=deployment.properties <https://protect-us.mimecast.com/s/qu2hCmZ0KltBVR2hG17Tz?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/PLLLCpYoNrU1gxDUGZA9z?domain=deployment.properties <https://protect-us.mimecast.com/s/oJtnCn5mLntA465tJuI58?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 > > _______________________________________________ > OVAL_Developer mailing list > OVAL_Developer@lists.cisecurity.org <mailto:OVAL_Developer@lists.cisecurity.org> > http://lists.cisecurity.org/mailman/listinfo/oval_developer_lists.cisecurity.org <http://lists.cisecurity.org/mailman/listinfo/oval_developer_lists.cisecurity.org>
VJ
Vanderpol, Jack R CIV USN SPAWARSYSCEN LANT SC (US)
Wed, Jul 25, 2018 12:30 PM

Sure I'll give it a try.

Jack Vander Pol
SPAWAR Systems Center Atlantic


From: David Solin [solin@jovalcm.com]
Sent: Tuesday, July 24, 2018 6:54 PM
To: Vanderpol, Jack R CIV USN SPAWARSYSCEN LANT SC (US)
Cc: oval_developer@lists.cisecurity.org
Subject: [Non-DoD Source] Re: [OVAL DEVELOPER] Oval feature recommendation string 'replace' function

All active links contained in this email were disabled. Please verify the identity of the sender, and confirm the authenticity of all links contained within the message prior to copying and pasting the address to a Web browser.


Hi Jack,

I was going to suggest: "why not use the ReplaceFunctionType" … but then I discovered there simply is no such thing!  I feel like someone proposed this before, but perhaps I only dreamed it.

I can’t think of any other way to achieve what you want to do.  Do you want to write up a proposal for a new function?

Best regards,
—David Solin

On Jul 24, 2018, at 2:28 PM, Vanderpol, Jack R CIV USN SPAWARSYSCEN LANT SC (US) <jack.r.vanderpol.civ@mail.mil < Caution-mailto:jack.r.vanderpol.civ@mail.mil > > wrote:

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/BJiLCADXBjCLx59sGUekJ?domain=deployment.properties < https://protect-us.mimecast.com/s/OS_GCBBXDlfpxNVU6b0SB?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/BJiLCADXBjCLx59sGUekJ?domain=deployment.properties < https://protect-us.mimecast.com/s/OS_GCBBXDlfpxNVU6b0SB?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/q0dUCDkZGptN7ZBTA8p-u?domain=deployment.properties < https://protect-us.mimecast.com/s/X09aCERXJriVwjWsPHssV?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


OVAL_Developer mailing list
OVAL_Developer@lists.cisecurity.org < Caution-mailto:OVAL_Developer@lists.cisecurity.org >
https://protect-us.mimecast.com/s/5WtJCG6XLyHKr9JFkjcVh < https://protect-us.mimecast.com/s/5WtJCG6XLyHKr9JFkjcVh >

Sure I'll give it a try. Jack Vander Pol SPAWAR Systems Center Atlantic ________________________________ From: David Solin [solin@jovalcm.com] Sent: Tuesday, July 24, 2018 6:54 PM To: Vanderpol, Jack R CIV USN SPAWARSYSCEN LANT SC (US) Cc: oval_developer@lists.cisecurity.org Subject: [Non-DoD Source] Re: [OVAL DEVELOPER] Oval feature recommendation string 'replace' function All active links contained in this email were disabled. Please verify the identity of the sender, and confirm the authenticity of all links contained within the message prior to copying and pasting the address to a Web browser. ________________________________ Hi Jack, I was going to suggest: "why not use the ReplaceFunctionType" … but then I discovered there simply is no such thing! I feel like someone proposed this before, but perhaps I only dreamed it. I can’t think of any other way to achieve what you want to do. Do you want to write up a proposal for a new function? Best regards, —David Solin On Jul 24, 2018, at 2:28 PM, Vanderpol, Jack R CIV USN SPAWARSYSCEN LANT SC (US) <jack.r.vanderpol.civ@mail.mil < Caution-mailto:jack.r.vanderpol.civ@mail.mil > > wrote: 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/BJiLCADXBjCLx59sGUekJ?domain=deployment.properties < https://protect-us.mimecast.com/s/OS_GCBBXDlfpxNVU6b0SB?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/BJiLCADXBjCLx59sGUekJ?domain=deployment.properties < https://protect-us.mimecast.com/s/OS_GCBBXDlfpxNVU6b0SB?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/q0dUCDkZGptN7ZBTA8p-u?domain=deployment.properties < https://protect-us.mimecast.com/s/X09aCERXJriVwjWsPHssV?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 _______________________________________________ OVAL_Developer mailing list OVAL_Developer@lists.cisecurity.org < Caution-mailto:OVAL_Developer@lists.cisecurity.org > https://protect-us.mimecast.com/s/5WtJCG6XLyHKr9JFkjcVh < https://protect-us.mimecast.com/s/5WtJCG6XLyHKr9JFkjcVh >