Diewalkure / owasp-esapi-java

Automatically exported from code.google.com/p/owasp-esapi-java
Other
1 stars 0 forks source link

Enchance encodeForOS to auto-detect the underling OS #133

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The encodeForOS function in the ESAPI for Java reference implementation should 
autodetect the OS, rather than require the caller to send in the type of OS to 
make it safe for. It should use the right codec automatically given the 
underlying OS, or throw some kind of notimplementedexception if it determines 
it’s on an OS that it doesn’t recognize (have an encoder for).

Original issue reported on code.google.com by manico.james@gmail.com on 26 Jul 2010 at 8:48

GoogleCodeExporter commented 9 years ago

Original comment by schal...@darkmist.net on 23 Sep 2010 at 3:14

GoogleCodeExporter commented 9 years ago
I'd like this done before 2.0GA.

Original comment by manico.james@gmail.com on 2 Nov 2010 at 7:57

GoogleCodeExporter commented 9 years ago
Would it be as simple as adding this to the encoder?

    public String encodeForOS(String input) {
        Codec codec;
        if ( System.getProperty("os.name").indexOf("Windows") != -1 ) {
            codec = new WindowsCodec();
        } else {
            codec = new UnixCodec();
        }
        return this.encodeForOS(codec, input);
    }

That method is very similiar to the constructor of the DefaultExecutor, it 
would probably be a good idea to create a method that would return the correct 
Codec for the current OS that both methods would call.

Original comment by brent.sh...@gmail.com on 7 Nov 2010 at 4:41

GoogleCodeExporter commented 9 years ago
Added affected component.

Original comment by kevin.w.wall@gmail.com on 12 Feb 2011 at 7:32

GoogleCodeExporter commented 9 years ago
Here's how I would implement it.

Original comment by brent.sh...@gmail.com on 10 Mar 2011 at 4:57

Attachments:

GoogleCodeExporter commented 9 years ago
This code looks fine to me, but it may make more sense to store
System.getProperty("os.name") in a static final String since it
should not really be changing dynamically once the Java VM starts
executing. (I.e., it should be constant; virtualization doesn't
migrate processes from one OS type to another.)

Original comment by kevin.w.wall@gmail.com on 21 Mar 2011 at 5:13

GoogleCodeExporter commented 9 years ago

Original comment by manico.james@gmail.com on 29 May 2012 at 3:25