<commit_before>package com.github.katjahahn;

import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.Map;

import com.github.katjahahn.coffheader.COFFFileHeader;
import com.github.katjahahn.coffheader.MachineType;
import com.github.katjahahn.optheader.DataDirEntry;
import com.github.katjahahn.optheader.DataDirectoryKey;
import com.github.katjahahn.sections.SectionLoader;
import com.github.katjahahn.sections.SectionTable;
import com.github.katjahahn.sections.debug.DebugDirTableKey;
import com.github.katjahahn.sections.debug.DebugSection;
import com.github.katjahahn.sections.edata.ExportSection;
import com.github.katjahahn.sections.idata.DirectoryTableEntry;
import com.github.katjahahn.sections.idata.DirectoryTableEntryKey;
import com.github.katjahahn.sections.idata.ImportDLL;
import com.github.katjahahn.sections.idata.ImportSection;
import com.github.katjahahn.sections.idata.NameImport;
import com.github.katjahahn.sections.idata.OrdinalImport;
import com.github.katjahahn.sections.rsrc.DataEntry;
import com.github.katjahahn.sections.rsrc.Resource;
import com.github.katjahahn.sections.rsrc.ResourceDirectoryEntry;
import com.github.katjahahn.sections.rsrc.ResourceDirectoryTable;
import com.github.katjahahn.sections.rsrc.ResourceDirectoryTableKey;
import com.github.katjahahn.sections.rsrc.ResourceSection;
import com.github.katjahahn.sections.rsrc.SubDirEntry;
import com.github.katjahahn.tools.Overlay;
import com.github.katjahahn.tools.sigscanner.Jar2ExeScanner;
import com.github.katjahahn.tools.sigscanner.MatchedSignature;
import com.github.katjahahn.tools.sigscanner.Signature;
import com.github.katjahahn.tools.sigscanner.SignatureScanner;

/**
 * These are the code examples for the PortEx Wiki.
 * <p>
 * If code changes have to be applied here, the Wiki for PortEx has to be
 * updated too.
 * 
 * @author <NAME>
 * 
 */
public class WikiExampleCodes {

    public void gettingStarted() throws IOException {
        // Header information
        // load the PE file data
        PEData data = PELoader.loadPE(new File("myfile"));

        // get various data from coff file header and print it
        COFFFileHeader coff = data.getCOFFFileHeader();
        MachineType machine = coff.getMachineType();
        Date date = coff.getTimeDate();
        int numberOfSections = coff.getNumberOfSections();
        int optionalHeaderSize = coff.getSizeOfOptionalHeader();

        System.out.println("machine type: "
                + COFFFileHeader.getDescription(machine));
        System.out.println("number of sections: " + numberOfSections);
        System.out.println("size of optional header: " + optionalHeaderSize);
        System.out.println("time date stamp: " + date);

        List<String> characteristics = coff.getCharacteristicsDescriptions();
        System.out.println("characteristics: ");
        for (String characteristic : characteristics) {
            System.out.println("\t* " + characteristic);<commit_msg>added anomalies to wiki codes<commit_after>package com.github.katjahahn;

import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.Map;

import com.github.katjahahn.coffheader.COFFFileHeader;
import com.github.katjahahn.coffheader.MachineType;
import com.github.katjahahn.optheader.DataDirEntry;
import com.github.katjahahn.optheader.DataDirectoryKey;
import com.github.katjahahn.sections.SectionLoader;
import com.github.katjahahn.sections.SectionTable;
import com.github.katjahahn.sections.debug.DebugDirTableKey;
import com.github.katjahahn.sections.debug.DebugSection;
import com.github.katjahahn.sections.edata.ExportSection;
import com.github.katjahahn.sections.idata.DirectoryTableEntry;
import com.github.katjahahn.sections.idata.DirectoryTableEntryKey;
import com.github.katjahahn.sections.idata.ImportDLL;
import com.github.katjahahn.sections.idata.ImportSection;
import com.github.katjahahn.sections.idata.NameImport;
import com.github.katjahahn.sections.idata.OrdinalImport;
import com.github.katjahahn.sections.rsrc.DataEntry;
import com.github.katjahahn.sections.rsrc.Resource;
import com.github.katjahahn.sections.rsrc.ResourceDirectoryEntry;
import com.github.katjahahn.sections.rsrc.ResourceDirectoryTable;
import com.github.katjahahn.sections.rsrc.ResourceDirectoryTableKey;
import com.github.katjahahn.sections.rsrc.ResourceSection;
import com.github.katjahahn.sections.rsrc.SubDirEntry;
import com.github.katjahahn.tools.Overlay;
import com.github.katjahahn.tools.anomalies.Anomaly;
import com.github.katjahahn.tools.anomalies.PEAnomalyScanner;
import com.github.katjahahn.tools.sigscanner.Jar2ExeScanner;
import com.github.katjahahn.tools.sigscanner.MatchedSignature;
import com.github.katjahahn.tools.sigscanner.Signature;
import com.github.katjahahn.tools.sigscanner.SignatureScanner;

/**
 * These are the code examples for the PortEx Wiki.
 * <p>
 * If code changes have to be applied here, the Wiki for PortEx has to be
 * updated too.
 * 
 * @author <NAME>
 * 
 */
public class WikiExampleCodes {
    
    public void fileAnomalies() {
        File file = new File("filepath");
        PEAnomalyScanner scanner = PEAnomalyScanner.newInstance(file);
        System.out.println(scanner.scanReport());
        
        scanner = PEAnomalyScanner.newInstance(file);
        List<Anomaly> anomalies = scanner.getAnomalies();
        for(Anomaly anomaly: anomalies) {
            System.out.println("Anomaly Type: " + anomaly.getType());
            System.out.println("Entry with anomaly: " + anomaly.field());
            System.out.println(anomaly.description());
            System.out.println();
        }
    }

    public void gettingStarted() throws IOException {
        // Header information
        // load the PE file data
        PEData data = PELoader.loadPE(new File("myfile"));

        // get various data from coff file header and print it
        COFFFileHeader coff = data.getCOFFFileHeader();
        MachineType machine = coff.getMachineType();
        Date date = coff.getTimeDate();
        int numberOfSections = coff.getNumberOfSections();
        int optionalHeaderSize = coff.getSizeOfOptionalHeader();

        System.out.println("machine type: "
                + COFFFileHeader.getDescription(machine));
        System.out.println("number of sections: " + numberOfSections);
        System.out.println("size of optional header: " + optionalHeaderSize);
        System.out.println("time date stamp: " + date);

        List<String> characteristics = coff.getCharacteristicsDescriptions();
        System.out.println("characteristics: ");
        for (String characteristic : characteristics) {
            System.out.println("\t* " + characteristic);
{'fraction_non_alphanumeric': 0.10418205999704448, 'fraction_numerical': 0.0002955519432540269, 'mean_word_length': 4.230293663060278, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2888591', 'n_tokens_mistral': 2069, 'n_tokens_neox': 1965, 'n_words': 365}