Quantalytics / pulledpork

Automatically exported from code.google.com/p/pulledpork
GNU General Public License v2.0
0 stars 0 forks source link

Q&D perl script to convert oinkmaster.cconf into pp sid lists #37

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
non comment lines other than disablesid, enablesid or modifysid go into pp.con

I've used this successfully on a couple of large oinkmaster.conf files

as always ymmv.

usage: perl oink-conv oinkmaster.conf

#! /usr/bin/perl -w

# simple script to convert oinkmaster conf files to the files that PulledPork 
understands... 

open(DIS, ">disabled.conf") || die "failed to open disabled file"; 
open(EN, ">enabled.conf") || die "failed to open enabled file"; 
open(MOD, ">modified.conf") || die "failed to open modified file"; 
open(PP, ">pp.conf" )|| die "failed to open pp.conf file"; 

while ( <> ) {
    chomp;
    s/^\s+//;
    next if /^#/;
    next if /^$/;
    s/(#.*)$//;   # remove comment
       $comment = $1 || '';
    if( s/^disablesid\s+//i ) {   #disablesid 184, 221, 230, 241, 251, 253, 254, 257

    print DIS "1:", join( ", 1:", split(/\s*,\s*/, $_ ) ), " # $comment\n";
    } elsif( s/^modifysid\s+//i ) {  #  modifysid 2001855  "type limit, count 1, seconds 360" | "type both, count 4, seconds 600"
    my @sids; #  = undef;
    while( s/^(\d+)// ) {
        push( @sids, $1);
        s/^\s*,\s*//;
    }
    print MOD "1:", join( ", 1:", @sids ), " $_ # $comment\n";

    } elsif( s/^enablesid\s+//i ) {
    print EN "1:", join( ", 1:", (split(/\s*,\s*/, $_ )) ), " # $comment\n";
    } else {
    print PP "$_\n";
    }
}

Original issue reported on code.google.com by russell....@gmail.com on 20 Oct 2010 at 10:59

GoogleCodeExporter commented 9 years ago
I'll create a contrib folder and put this in it, thanks for the contribution!

Original comment by Cummin...@gmail.com on 20 Oct 2010 at 11:18

GoogleCodeExporter commented 9 years ago
Oops!  Just realised that I need to distinguish between dynamic rules and 
ordinary rules and put the correct genid in.

Will fix and resubmit!

Original comment by russell....@gmail.com on 4 Nov 2010 at 12:43