Changeset 1989

Show
Ignore:
Timestamp:
03/10/08 09:24:37 (9 months ago)
Author:
apatel
Message:

merged trunk:1988 to the branch.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/custome_policy/framework-plugin/.options

    r1764 r1989  
    99com.tresys.cdsframework/debug/navigator=false 
    1010com.tresys.cdsframework/debug/graphiceditor=false 
     11com.tresys.cdsframework/debug/accesschecks=false 
  • branches/custome_policy/framework-plugin/.settings/org.eclipse.jdt.ui.prefs

    r1763 r1989  
    1 #Wed Nov 21 11:46:43 EST 2007 
     1#Mon Mar 03 14:34:58 EST 2008 
    22eclipse.preferences.version=1 
    33formatter_profile=_Project Format 
  • branches/custome_policy/framework-plugin/META-INF/MANIFEST.MF

    r1924 r1989  
    1919 org.eclipse.help, 
    2020 com.tresys.cdsframework.libselinuxjava, 
    21  com.tresys.slide;bundle-version="1.3.7", 
     21 com.tresys.slide;bundle-version="1.3.9", 
    2222 com.tresys.cdsframework.doc.user;resolution:=optional, 
    2323 com.tresys.setools;bundle-version="3.3.2.1", 
  • branches/custome_policy/framework-plugin/plugin.properties

    r1987 r1989  
    4444## builder 
    4545frameworkBuilder = CDS Framework Builder 
     46AccessCheckBuilder = Access Check Builder 
    4647 
    4748## plugin Preferences 
  • branches/custome_policy/framework-plugin/plugin.xml

    r1987 r1989  
    6262      </editor>     
    6363   </extension> 
     64   <extension 
     65         id="AccessCheckBuilder" 
     66         name="%AccessCheckBuilder" 
     67         point="org.eclipse.core.resources.builders"> 
     68      <builder 
     69            callOnEmptyDelta="false" 
     70            hasNature="false" 
     71            isConfigurable="false"> 
     72         <run 
     73               class="com.tresys.framework.plugin.builder.AccessCheckBuilder"> 
     74         </run> 
     75      </builder> 
     76   </extension> 
    6477    
    6578   <extension 
     
    6780         name="%frameworkBuilder" 
    6881         point="org.eclipse.core.resources.builders">          
    69       <builder hasNature="true"> 
     82      <builder 
     83            hasNature="true" 
     84            isConfigurable="false"> 
    7085         <run class="com.tresys.framework.plugin.builder.FrameworkBuilder"/> 
    7186      </builder> 
     
    8297      <requires-nature id="com.tresys.slide.SystemProjectNature"/> 
    8398      <requires-nature id="com.tresys.slide.SLIDEProject"/> 
     99      <builder 
     100            id="com.tresys.framework.AccessCheckBuilder"> 
     101      </builder> 
    84102   </extension> 
    85103    
  • branches/custome_policy/framework-plugin/resources/build/Makefile

    • Property svn:keywords set to Date Author Id Revision
  • branches/custome_policy/framework-plugin/resources/cdsframework.spt

    • Property svn:keywords set to Date Author Id Revision
    r1949 r1989  
     1# 
     2# Support macros for CDS Framework 
     3# 
     4# Copyright (C) 2005-2008 Tresys Technology, LLC 
     5# License: refer to COPYING file for license information. 
     6# Authors: Spencer Shimko <sshimko@tresys.com> 
     7#               James Athey <jathey@tresys.com>  
     8#               Brian Williams <bwilliams@tresys.com> 
     9#               Dave Sugar <dsugar@tresys.com> 
     10# 
     11# $Rev$ 
     12# $Date$ 
     13# 
     14 
    115define(`SEFramework_header',` 
    216        policy_module($1,1.0) 
     
    2438 
    2539define(`SEFramework_dir_context',` 
    26         $1(/.*)?                gen_context(system_u:object_r:$2,s0
     40        $1(/.*)?                gen_context(system_u:object_r:$2,$3
    2741') 
    2842 
    2943define(`SEFramework_file_context',` 
    30         $1      --      gen_context(system_u:object_r:$2,s0
     44        $1      --      gen_context(system_u:object_r:$2,$3
    3145') 
    3246 
  • branches/custome_policy/framework-plugin/resources/conf/selinux-policy.spec

    • Property svn:keywords set to Date Author Id Revision
  • branches/custome_policy/framework-plugin/resources/dictionary/dictionary.fdic

    • Property svn:keywords set to Date Author Id Revision
  • branches/custome_policy/framework-plugin/resources/link/etc_files.flnk

    • Property svn:keywords set to Date Author Id Revision
  • branches/custome_policy/framework-plugin/resources/link/eth0.flnk

    • Property svn:keywords set to Date Author Id Revision
  • branches/custome_policy/framework-plugin/resources/link/eth1.flnk

    • Property svn:keywords set to Date Author Id Revision
  • branches/custome_policy/framework-plugin/resources/link/exec_bin.flnk

    • Property svn:keywords set to Date Author Id Revision
  • branches/custome_policy/framework-plugin/resources/link/init.flnk

    • Property svn:keywords set to Date Author Id Revision
  • branches/custome_policy/framework-plugin/resources/link/locale.flnk

    • Property svn:keywords set to Date Author Id Revision
  • branches/custome_policy/framework-plugin/resources/link/read_all_files.flnk

    • Property svn:keywords set to Date Author Id Revision
  • branches/custome_policy/framework-plugin/resources/link/root_d.flnk

    • Property svn:keywords set to Date Author Id Revision
  • branches/custome_policy/framework-plugin/resources/link/run_x.flnk

    • Property svn:keywords set to Date Author Id Revision
  • branches/custome_policy/framework-plugin/resources/link/unconfined.flnk

    • Property svn:keywords set to Date Author Id Revision
  • branches/custome_policy/framework-plugin/resources/link/user.flnk

    • Property svn:keywords set to Date Author Id Revision
  • branches/custome_policy/framework-plugin/resources/link/write_log_file.flnk

    • Property svn:keywords set to Date Author Id Revision
  • branches/custome_policy/framework-plugin/src/com/tresys/framework/compiler/Compiler.java

    r1949 r1989  
    55 *              James Athey <jathey@tresys.com> 
    66 *              Brian Williams <bwilliams@tresys.com> 
     7 *                      Dave Sugar <dsugar@tresys.com> 
    78 *   
    89 * Compiler: Compiler main 
     
    2526import com.tresys.framework.compiler.dictionary.DictionaryValidator; 
    2627import com.tresys.framework.compiler.linkage.Linkage; 
     28import com.tresys.framework.compiler.mls.MLSInitializationException; 
     29import com.tresys.framework.compiler.mls.MLSSupport; 
    2730import com.tresys.framework.compiler.policy.Policy; 
    2831import com.tresys.framework.compiler.policy.PolicyValidator; 
     
    5760 
    5861        static String dictionarySupportFile = null; 
     62 
     63        static String mlsFilename = null; 
    5964         
    6065        static String libPath = System.getProperty ("user.dir") + "/libselinuxjava/libselinuxjava.so"; 
     
    155160                                } 
    156161                        } 
    157                         else if (args[x].equals ("-s")) 
     162                        else if (args[x].equals ("-m")) 
     163                        { 
     164                                x++; 
     165                                if (x < args.length) 
     166                                { 
     167                                        mlsFilename = args[x]; 
     168                                } 
     169                                else 
     170                                { 
     171                                        printUsage (); 
     172                                        System.exit (1); 
     173                                } 
     174                        } 
     175                        else if(args[x].equals("-s"))  
    158176                        { 
    159177                                x++; 
     
    307325                System.out.println ("  -if <interface file> specify interface file for linkage to reference policy"); 
    308326                System.out.println ("       and exposing an external API (defaults to stdout if not specified)"); 
     327                System.out.println ("  -m <mls file> specify mls inforation file for linkage to translate MLS labels"); 
     328                System.out.println ("       into real sensitivities (defaults to s0 for all if not specified)"); 
    309329                System.out.println (); 
    310330                System.out.println ("A dictionary file must be specified."); 
     
    337357                Utility.SetProjectErrorHandler (new CLIProjectErrorHandler ()); 
    338358 
     359                MLSSupport mlsSupport = null; 
     360                try 
     361                { 
     362                        if (mlsFilename != null) 
     363                        { 
     364                                if (debug) 
     365                                        System.out.println ("load MLS file: " + mlsFilename); 
     366                                File mlsFile = new File (mlsFilename); 
     367                                if (!mlsFile.exists ()) 
     368                                        System.err.println ("Specified MLS file not found: " + mlsFilename); 
     369                                else 
     370                                        mlsSupport = new MLSSupport (mlsFile); 
     371                                 
     372                        } 
     373                } 
     374                catch (MLSInitializationException mie) 
     375                { 
     376                        System.err.println ("Error initializing MLS information from: " + mlsFilename); 
     377                        System.err.println ("  Reason: " + mie.getMessage ()); 
     378                        if (debug) 
     379                                mie.printStackTrace (System.out); 
     380                        mlsSupport = null; 
     381                } 
     382                 
    339383                // create linkage interface depending on compilation targets 
    340                 linkage = new Linkage (flaskPath); 
     384                linkage = new Linkage(flaskPath, mlsSupport); 
    341385 
    342386                // attempt to create Dictionary 
  • branches/custome_policy/framework-plugin/src/com/tresys/framework/compiler/ErrorHandler.java

    r1949 r1989  
    3939        static final public int ERROR_UNABLE_TO_GET_TYPE_FROM_PATH = 30; 
    4040 
    41  
     41        static final public int ERROR_TE_ACCESS_DENIED = 31; 
     42        static final public int ERROR_CONSTRAINT_ACCESS_DENIED = 32; 
     43        static final public int ERROR_RBAC_ACCESS_DENIED = 33; 
     44         
    4245        protected int warningCount = 0; 
    4346 
     
    5255        { 
    5356                return errorCount; 
     57        } 
     58         
     59        public void resetErrorCounts () 
     60        { 
     61                warningCount = 0; 
     62                errorCount = 0; 
    5463        } 
    5564 
  • branches/custome_policy/framework-plugin/src/com/tresys/framework/compiler/PolicyGenerator.java

    r1949 r1989  
    2222import com.tresys.framework.compiler.linkage.flnkage.BaseAccessDefn; 
    2323import com.tresys.framework.compiler.policy.Ability; 
     24import com.tresys.framework.compiler.mls.MLSLevel; 
    2425import com.tresys.framework.compiler.policy.AccessBaseResource; 
    2526import com.tresys.framework.compiler.policy.AccessBoolean; 
     
    3334import com.tresys.framework.compiler.policy.Enter; 
    3435import com.tresys.framework.compiler.policy.EntrypointResource; 
     36import com.tresys.framework.compiler.policy.IMLSSetting; 
    3537import com.tresys.framework.compiler.policy.IPolicyVisitor; 
    3638import com.tresys.framework.compiler.policy.Policy; 
     
    7375                        buf.append(" }"); 
    7476                } 
     77                 
     78                appendMLSLevel (buf, i_resource); 
     79                 
    7580                buf.append(";"); 
    7681                buf.append(newLine); 
     
    115120                        buf.append("}"); 
    116121                } 
     122                 
     123                appendMLSLevel (buf, i_domain); 
     124                 
    117125                buf.append(";"); 
    118126                buf.append(newLine); 
     
    125133                StringBuffer buf = new StringBuffer(); 
    126134 
    127                 buf.append("entrypoint " + i_ep.getName() + ";"); 
     135                buf.append("entrypoint "); 
     136                buf.append(i_ep.getName()); 
     137                 
     138                appendMLSLevel (buf, i_ep); 
     139                 
     140                buf.append(";"); 
    128141                buf.append(newLine); 
    129142 
     
    399412                return fullResult.toString(); 
    400413        } 
     414         
     415        private void appendMLSLevel (StringBuffer i_buf, IMLSSetting i_mlsLevel) 
     416        { 
     417                if (i_mlsLevel == null) 
     418                        return; 
     419                 
     420                MLSLevel mlsLevel = i_mlsLevel.getMLSLevel (); 
     421                if (mlsLevel == null) 
     422                        return; 
     423                 
     424                i_buf.append (" \""); 
     425                i_buf.append (mlsLevel.getName ()); 
     426                i_buf.append ('"'); 
     427        } 
    401428} 
  • branches/custome_policy/framework-plugin/src/com/tresys/framework/compiler/linkage/Linkage.java

    r1949 r1989  
    66 * 
    77 * Linkage.java: Contains linkage class for framework->t.e. conversion 
    8  * Version: @version@ 
     8 *  
     9 * $Rev$ 
     10 * $Date$ 
    911 */ 
    1012 
     
    1820 
    1921import com.tresys.framework.compiler.policy.Ability; 
     22import com.tresys.framework.compiler.mls.MLSLevel; 
     23import com.tresys.framework.compiler.mls.MLSSupport; 
    2024import com.tresys.framework.compiler.policy.BaseDomain; 
    2125import com.tresys.framework.compiler.policy.BaseResource; 
    2226import com.tresys.framework.compiler.policy.Conditional; 
     27import com.tresys.framework.compiler.policy.IMLSSetting; 
    2328 
    2429/** 
     
    2833 * separation was done to aide in policy version independence. 
    2934 */ 
    30 public final class Linkage { 
     35public final class Linkage  
     36
    3137 
    3238        /** delimiter that separates rdef names from id's in type names */ 
     
    4652 
    4753        private final BasePolicy BasePolicy; 
    48  
     54        private final MLSSupport m_MLSSupport; 
     55         
     56         
    4957        /** 
    5058         * Linkage to base policy. 
     
    5462         * @throws Exception    If memory allocation fails 
    5563         */ 
    56         public Linkage(String flaskPath)  
     64        public Linkage (String flaskPath, MLSSupport i_support)  
    5765        { 
    5866                BasePolicy = new BasePolicy(flaskPath); 
     
    6068                availableBaseResources = new HashMap/*<String, BaseResource>*/(); 
    6169                capabilities = new HashMap(); 
     70                m_MLSSupport = i_support; 
    6271        } 
    6372         
     
    6776        } 
    6877 
     78        public MLSSupport getMLSSupport () 
     79        { 
     80                return m_MLSSupport; 
     81        } 
     82         
    6983        /** 
    7084         * This method should return a string that may perform some basic 
     
    7286         * policy translation is performed. 
    7387         */ 
    74         public void InitPolicy(PrintStream ps, String moduleName) { 
     88        public void InitPolicy(PrintStream ps, String moduleName)  
     89        { 
    7590                ps.print("SEFramework_header(" + moduleName + ")\n"); 
    7691        } 
     
    8095         * interface initialization tasks. 
    8196         */ 
    82         public void InitInterface(PrintStream ps) { 
     97        public void InitInterface(PrintStream ps)  
     98        { 
    8399                ps.print("## <summary>SEFramework generated interface.</summary>\n"); 
    84100        } 
     
    89105         * translation is performed. 
    90106         */ 
    91         public void InitFileContext(PrintStream ps) {} 
     107        public void InitFileContext(PrintStream ps)  
     108        {} 
    92109 
    93110        /** 
     
    96113         * translation is performed. 
    97114         */ 
    98         public void InitNetwork(PrintStream ps) {} 
     115        public void InitNetwork(PrintStream ps)  
     116        {} 
    99117 
    100118        /** 
     
    106124         * @return              String defining the domain in the underlying policy language. 
    107125         */ 
    108         public void MakeDomain(String name, PrintStream ps) { 
     126        public void MakeDomain(String name, PrintStream ps)  
     127        { 
    109128                // TODO currently only allows the system to start our domains 
    110129                ps.print("SEFramework_domain(" + name + ")\n"); 
     
    119138         * @return              String defining the domain in the underlying policy language. 
    120139         */ 
    121         public void MakeResource(String name, PrintStream ps) { 
     140        public void MakeResource(String name, PrintStream ps)  
     141        { 
    122142                ps.print("SEFramework_resource(" + name + ")\n"); 
    123143        } 
     
    131151         * @return              String defining the domain in the underlying policy language. 
    132152         */ 
    133         public void MakeEntrypoint(String name, PrintStream ps) { 
     153        public void MakeEntrypoint(String name, PrintStream ps)  
     154        { 
    134155                ps.print("SEFramework_entrypoint(" + name + ")\n"); 
    135156        } 
     
    141162         * @return  Assignment statement 
    142163         */ 
    143         public void MakeFileType(String type, PrintStream ps) { 
     164        public void MakeFileType(String type, PrintStream ps)  
     165        { 
    144166                ps.print("SEFramework_files_type(" + type + ")\n"); 
    145167        } 
     
    151173         * @param con           The context for the context entry. 
    152174         */ 
    153         public void MakeDirContext(String path, String con, PrintStream ps) { 
    154                 ps.print("SEFramework_dir_context(" + path + ", " + con + ")\n"); 
     175        public void MakeDirContext(String path, String con, IMLSSetting i_mls, PrintStream ps)  
     176        { 
     177                String sSensitivity = "s0"; 
     178                if (i_mls != null && m_MLSSupport != null) 
     179                { 
     180                        MLSLevel level = m_MLSSupport.getLevel (i_mls.getMLSLabel ()); 
     181                        if (level != null) 
     182                                sSensitivity = level.getRange (); 
     183                } 
     184                 
     185                 
     186                ps.print("SEFramework_dir_context(" + path + ", " + con + ", " + sSensitivity + ")\n"); 
    155187        } 
    156188 
     
    160192         * @param con           The context for the context entry. 
    161193         */ 
    162         public void MakeBoolean(Conditional bool, PrintStream ps) { 
     194        public void MakeBoolean(Conditional bool, PrintStream ps)  
     195        { 
    163196                ps.print("bool " + bool.getName() + " " + bool.getDefaultState() 
    164197                        + ";\n"); 
     
    173206         * @param con           The context for the context entry. 
    174207         */ 
    175         public void MakeFileContext(String path, String con, PrintStream ps) { 
    176                 ps.print("SEFramework_file_context(" + path + ", " + con + ")\n"); 
    177         } 
    178  
    179         public void MakeUserDomain(String name, PrintStream ps) { 
     208        public void MakeFileContext(String path, String con, IMLSSetting i_mls, PrintStream ps)  
     209        { 
     210                String sSensitivity = "s0"; 
     211                if (i_mls != null && m_MLSSupport != null) 
     212                { 
     213                        MLSLevel level = m_MLSSupport.getLevel (i_mls.getMLSLabel ()); 
     214                        if (level != null) 
     215                                sSensitivity = level.getRange (); 
     216                } 
     217                 
     218                ps.print("SEFramework_file_context(" + path + ", " + con + ", " + sSensitivity + ")\n"); 
     219        } 
     220 
     221        public void MakeUserDomain(String name, PrintStream ps)  
     222        { 
    180223                ps.print("SEFramework_user_domain(" + name + ")\n"); 
    181224        } 
    182225 
    183         public void CanReadBoolean(String domain, String boolType, PrintStream ps) { 
     226        public void CanReadBoolean(String domain, String boolType, PrintStream ps)  
     227        { 
    184228                ps 
    185229                        .print("SEFramework_read_boolean(" + domain + ", " + boolType 
     
    187231        } 
    188232 
    189         public void CanWriteBoolean(String domain, String boolType, PrintStream ps) { 
     233        public void CanWriteBoolean(String domain, String boolType, PrintStream ps)  
     234        { 
    190235                ps.print("SEFramework_set_boolean(" + domain + ", " + boolType + ")\n"); 
    191236        } 
  • branches/custome_policy/framework-plugin/src/com/tresys/framework/compiler/linkage/flnkage/FLNKParser.jj

    r1949 r1989  
    414414        <SEMICOLON> 
    415415        { 
    416                 domain.SetType(type.image); 
     416                domain.setType(type.image); 
    417417                Utility.Debug("Type " + type.image + " added to BaseDomain " + domain.getName()); 
    418418        } 
     
    429429        role = <ID> 
    430430        { 
    431                 domain.SetRole(role.image); 
     431                domain.setRole(role.image); 
    432432        } 
    433433        <SEMICOLON> 
  • branches/custome_policy/framework-plugin/src/com/tresys/framework/compiler/mls/MLSLevel.java

    r1915 r1989  
    2323import org.w3c.dom.Document; 
    2424import org.w3c.dom.Element; 
     25import org.w3c.dom.NamedNodeMap; 
     26import org.w3c.dom.Node; 
    2527 
    2628/** 
     
    3234 * 
    3335 */ 
    34 public class MLSLevel 
     36public class MLSLevel  
    3537{ 
     38        private static final String COLOR_ATTRIBUTE_NAME = "color"; 
     39 
     40        public static final String EMPTY_STRING = new String (); 
     41 
     42        private static final String LEVEL_ELEMENT_NAME = "level"; 
     43 
     44        private static final String NAME_ATTRIBUTE_NAME = "name"; 
     45 
     46        private static final String ORDER_ATTRIBUTE_NAME = "order"; 
     47