Changeset d9c3886


Ignore:
Timestamp:
05/18/12 00:58:12 (13 months ago)
Author:
Mei <mei@…>
Branches:
mei_rt2, mei_rt2_fix_1
Children:
0b3ac65
Parents:
5110d42
git-author:
Mei <mei@…> (05/18/12 00:58:12)
git-committer:
Mei <mei@…> (05/18/12 00:58:12)
Message:

1) add 2 more query calls in abac.hh that take Role and Oset instead of

strings. Add supporting code in libabac that will take abac_aspect_t
and make query term directly instead of doing stringify the structure
and do string->yyparse->abac_aspect_t again.

2) start on inline doc into abac.hh
3) tweaked some scripts in examples directory

Files:
16 edited

Legend:

Unmodified
Added
Removed
  • examples/creddy_prover_tests/allout.save

    r5110d42 rd9c3886  
    4646   
    4747===bad============ Acme.preferred_customer <- badCoyote 
    48 yyerror: encountered an invalid SHA id(bad) 
     48yyerror: encountered an invalid SHA id 
    4949prover failed!! 
    5050 
     
    6464   
    6565===bad============ 99Acme.buy_rockets <- Coyote 
    66 yyerror: encountered an invalid SHA id(994956018dbb522c97da1e0f19d7713510b14eb712) 
     66yyerror: encountered an invalid SHA id 
    6767prover failed!! 
    6868   
  • examples/creddy_prover_tests/runall

    r5110d42 rd9c3886  
    77 
    88progname=$(basename $0) 
     9pwd=`pwd` 
    910 
    1011if [ $# -eq 0 ]; then 
     
    1718 
    1819for i in `ls -1 `; do 
    19    if ( file $i | grep -Fq directory ); then 
    20        cd $i; 
     20   if [ -d $i ]; then 
     21       cd $i 
    2122       if [ "$1" = "clean" ]; then 
    2223           rm -rf ../allout.sha ../allout.cn 
     
    3031           ./run_query  
    3132       fi  
    32        cd ..; 
     33       cd $pwd 
    3334   fi 
    3435done 
  • examples/creddy_prover_tests/runcheck

    r5110d42 rd9c3886  
    66export ABAC_PROVER_PATH 
    77 
    8 echo 'running ABAC testing...' 
     8echo 'running libabac CREDDY/ABAC_PROVER_YAP testing...' 
    99echo '  ---with sha' 
    1010env ./runall run 1> allout.sha 2>/dev/null 
  • examples/python_tests/allout.save

    r5110d42 rd9c3886  
    11 
    2  ==> RUN on basic_api 
    3 ---setup precondition 
    4 Generating key, this will take a while. Create entropy! 
    5     - move the mouse 
    6     - generate disk activity (run find) 
    7 Generating key, this will take a while. Create entropy! 
    8     - move the mouse 
    9     - generate disk activity (run find) 
     2 ==> RUN on access_rt2 
     3---setup principals 
     4---setup attributes 
     5---run queries 
     6...with sha 
     7...with cn 
     8   PASSED 
     9 
     10 ==> RUN on basic_id 
     11---setup principals 
    1012---run with sha 
    1113---run with cn 
  • examples/python_tests/basic_id/README

    r5110d42 rd9c3886  
    66# In yap db, the ID credential is stored as: isType(pIDname,keyid) 
    77 
    8 # Two pre-existing id credentials are generated using creddy, this is 
    9 # to test the load_directory api call 
    10 creddy --generate --cn CreddyBob 
    11 creddy --generate --cn CreddyJack 
    128 
    139 
  • examples/python_tests/basic_id/id.py

    r5110d42 rd9c3886  
    4343id=ABAC.ID("John", 0) 
    4444print "adding -> %s(good,invisible)" % id.name() 
    45 id.write_privkey("John_idkey.pem") 
    46 id.write_cert("John_idkey.pem") 
    47 ctxt.load_id_file("John_idkey.pem") 
     45id.write_privkey("John_other.pem") 
     46id.write_cert("John_other.pem") 
     47ctxt.load_id_file("John_other.pem") 
    4848 
    4949id=ABAC.ID("Lori", 0) 
  • examples/python_tests/basic_id/id.save

    r5110d42 rd9c3886  
    33ABAC version 1.0 
    44...initial principal set... 
    5 (pCreddyBob,keyid,y)  
    6 (pCreddyJack,keyid,y)  
     5(pBob,keyid,y)  
     6(pJack,keyid,y)  
    77(pMary,keyid,y)  
    88(pLori,keyid,n)  
     
    1818adding -> Casper(bad,unknown file) 
    1919...final principal set... 
    20 (pCreddyBob,keyid,y)  
    21 (pCreddyJack,keyid,y)  
     20(pBob,keyid,y)  
     21(pJack,keyid,y)  
    2222(pMary,keyid,y)  
    2323(pLori,keyid,n)  
     
    3030 
    3131========= yap db (dump_yap) 
    32 isType(pCreddyBob,keyid). 
    33 isType(pCreddyJack,keyid). 
     32isType(pBob,keyid). 
     33isType(pJack,keyid). 
    3434isType(pMary,keyid). 
    3535isType(pLori,keyid). 
  • examples/python_tests/basic_id/run_test

    r5110d42 rd9c3886  
    88 
    99echo '---setup principals' 
    10 ./README 
     10./setup.py 2>/dev/null 1 > id.sha 
    1111 
    1212echo '---run with sha' 
  • examples/python_tests/runall

    r5110d42 rd9c3886  
    66 
    77progname=$(basename $0) 
     8pwd=`pwd` 
    89 
    910if [ $# -eq 0 ]; then 
    10     echo "Usage: $progname (clean|setup|run)" >&2; 
     11    echo "Usage: $progname (clean|run)" >&2; 
    1112    exit 1 
    1213fi 
     
    1617 
    1718for i in `ls -1 `; do 
    18    if ( file $i | grep -Fq directory ); then 
    19        cd $i; 
     19   if [ -d $i ]; then 
     20       cd $i 
    2021       if [ "$1" = "clean" ]; then 
    2122           rm -rf ../allout.tmp 
    2223           printf "\n ==> CLEANING on %s\n" "$i" >& 2 ; 
    2324           rm -rf *.der *.pem *.cn *.sha 
    24        elif [ "$1" = "setup" ]; then 
    25            printf "\n ==> SETUP on %s\n" "$i"  >& 2; 
    26            ./README 
    2725       elif [ "$1" = "run" ] ; then 
    28            if(file run_test | grep -vq ERROR); then 
    29                printf "\n ==> RUN on %s\n" "$i" >& 2; 
    30                ./run_test 
    31            fi 
     26           printf "\n ==> RUN on %s\n" "$i" >& 2; 
     27           ./run_test 
    3228       fi  
    33        cd ..; 
     29       cd $pwd 
    3430   fi 
    3531done 
  • examples/python_tests/runcheck

    r5110d42 rd9c3886  
    66export ABAC_PROVER_PATH 
    77 
    8 echo 'running PYTHON testing...' 
     8echo 'running libabac PYTHON testing...' 
    99 
    1010env ./runall run 1> allout.tmp 2>& 1 
  • libabac/abac.c

    r5110d42 rd9c3886  
    297297} 
    298298 
     299abac_credential_t **abac_context_query_with_structure(abac_context_t *ctx, 
     300abac_aspect_t *queryfor, abac_aspect_t *with, int *success) 
     301{ 
     302    if(debug) { 
     303         printf("abac_context_query_with_structure\n"); 
     304    } 
     305    abac_credential_t **credentials = NULL, *cur; 
     306    assert(ctx != NULL); assert(queryfor != NULL); 
     307    assert(with != NULL); assert(success != NULL); 
     308 
     309    abac_stack_t *result = abac_pl_query_with_structure(ctx->pl, queryfor, with); 
     310 
     311    int size = abac_stack_size(result); 
     312    if (size > 0) { 
     313        *success = 1; 
     314    } else { 
     315    // XXX NOT SURE YET.. 
     316    // return partial proof 
     317        *success = 0; 
     318    } 
     319 
     320    // make the array (leave space to NULL terminate it) 
     321    //      n.b., even if the list is empty, we still return an array that 
     322    //            only contains the NULL terminator 
     323    credentials = abac_xmalloc(sizeof(abac_credential_t *) * (size + 1)); 
     324    int i = 0; 
     325    if(size) { 
     326        while(i<size) {  
     327            cur=(abac_credential_t *) abac_stack_pop(result); 
     328            credentials[i++] = cur; 
     329        }  
     330    } 
     331    credentials[i] = NULL; 
     332 
     333    if(result) 
     334        abac_stack_free(result); 
     335 
     336    return credentials; 
     337} 
     338 
    299339/** 
    300340 * A NULL-terminated array of all the credentials in the context. 
  • libabac/abac.h

    r5110d42 rd9c3886  
    4343/* abac query, returns a NULL-terminated array of credentials on success, NULL on fail */ 
    4444abac_credential_t **abac_context_query(abac_context_t *ctx, char *role, char *principal, int *success); 
     45abac_credential_t **abac_context_query_with_structure(abac_context_t *, abac_aspect_t*, abac_aspect_t*, int*); 
    4546 
    4647/* get all the credentials from the context, returns a NULL-terminated array of credentials */ 
  • libabac/abac.hh

    r5110d42 rd9c3886  
    1515    class Oset; 
    1616 
     17/***  
     18ABAC::Constraint 
     19   This is a constraint on a data term. It holds a ptr to 
     20   a abac_condition_t structure  
     21***/ 
    1722    class Constraint { 
    1823        public: 
    19             Constraint() : m_constraint(NULL) { } // do not use: here for swig 
     24/*** 
     25   Constraint() 
     26      default constructure, do not use, for swig only  
     27   Constraint(const Constraint &) 
     28      copy constructor, used for cloning a constraint 
     29   ~Constraint() 
     30      default destructor 
     31***/ 
     32            Constraint() : m_constraint(NULL) { } 
     33            Constraint(const Constraint &constraint) {  
     34                m_constraint =abac_condition_dup(constraint.m_constraint); 
     35              } 
     36            ~Constraint() {  
     37                if(m_constraint) abac_condition_free(m_constraint); 
     38              } 
     39 
     40/*** 
     41   Constraint(abac_condition_t *) 
     42      constructor that takes an abac_condition_t 
     43   Constraint(char *) 
     44      constructor that takes one of following string 
     45      as its vartype for a range constraint: 
     46          "integer" 
     47          "urn" 
     48          "float" 
     49          "boolean" 
     50          "time" 
     51          "string" 
     52***/ 
    2053            Constraint(abac_condition_t *constraint):  
    2154              m_constraint(abac_condition_dup(constraint)) 
    2255              { } 
    23             Constraint(const Constraint &constraint) {  
    24                 m_constraint =abac_condition_dup(constraint.m_constraint); 
    25               } 
    26             ~Constraint() {  
    27                 if(m_constraint) abac_condition_free(m_constraint); 
    28               } 
    29  
    3056            /* range constraint */ 
    3157            Constraint(char *vartype) { m_constraint=abac_condition_create(vartype); } 
    3258 
    33             /* [integer:?I[10 .. 20] */ 
    34             /* [float:?F[0.5 .. 2.5] */ 
     59/*** 
     60    void add_constraint_integer_max(int) 
     61    void add_constraint_integer_min(int) 
     62       Utility routines to setup a integer range constraint  
     63           [integer:?I[10 .. 20] 
     64    void add_constraint_integer_target(int) 
     65       Utility routine to setup a integer list constraint  
     66           [integer:?I[10,20] 
     67***/ 
    3568            void add_constraint_integer_max(int val) { 
    3669                abac_condition_add_range_integer_item(m_constraint,abac_max_item_type(),val); 
     
    4275                abac_condition_add_range_integer_item(m_constraint,abac_target_item_type(),val); 
    4376            } 
     77/*** 
     78    void add_constraint_float_max(float) 
     79    void add_constraint_float_min(float) 
     80       Utility routines to setup a float range constraint  
     81           [float:?F[1.0 .. 2.5] 
     82    void add_constraint_float_target(float) 
     83       Utility routine to setup a float list constraint  
     84            [float:?F[0.5, 2.5] 
     85***/ 
    4486            void add_constraint_float_max(float val) { 
    4587                abac_condition_add_range_float_item(m_constraint,abac_max_item_type(),val); 
     
    683725                 int i, success_int; 
    684726 
    685                  /* make sure retrieving SHA not CN embedded string */ 
    686                  ABAC_IN_QUERY=1; 
    687                  char *role_str=role.typed_string(); 
    688                  char *p_role_str=p_role.typed_string(); 
    689                  ABAC_IN_QUERY=0; 
    690                  if(debug) {  
    691                      printf("query with %s\n",role_str); 
    692                      printf("    and %s\n",p_role_str); 
    693                  } 
    694                  creds = abac_context_query(m_ctx, role_str, p_role_str, &success_int); 
     727                 creds = abac_context_query_with_structure(m_ctx, role.role(), p_role.role(), &success_int); 
    695728                 success = success_int; 
    696729 
     
    702735 
    703736                 abac_context_credentials_free(creds); 
    704                  free(role_str); 
    705                  free(p_role_str); 
    706737 
    707738                 return attributes; 
     
    711742                 abac_credential_t **creds, **end; 
    712743                 int i, success_int; 
    713                  /* make sure retrieving SHA not CN embedded string */ 
    714744               
    715                  ABAC_IN_QUERY++; 
    716                  char *oset_str=oset.typed_string(); 
    717                  char *p_oset_str=p_oset.typed_string(); 
    718                  ABAC_IN_QUERY--; 
    719  
    720                  creds = abac_context_query(m_ctx, oset_str, p_oset_str, &success_int); 
     745                 creds = abac_context_query_with_structure(m_ctx, oset.oset(), p_oset.oset(), &success_int); 
    721746                 success = success_int; 
    722747 
     
    729754 
    730755                 abac_context_credentials_free(creds); 
    731                  free(oset_str); 
    732                  free(p_oset_str); 
    733756 
    734757                 return attributes; 
  • libabac/abac_pl_yap.c

    r5110d42 rd9c3886  
    384384} 
    385385 
     386abac_stack_t *abac_pl_query_with_structure(abac_pl_t *pl, abac_aspect_t *head_aspect, abac_aspect_t *tail_aspect) 
     387{ 
     388    abac_stack_t *ret=NULL; 
     389    ret=_query_with_aspect(pl,head_aspect,tail_aspect); 
     390 
     391    return ret; 
     392} 
     393 
    386394void abac_pl_free(abac_pl_t *pl) { 
    387395    if(pl->fptr) { 
  • libabac/abac_pl_yap.h

    r5110d42 rd9c3886  
    1717/* return a list of credentials */ 
    1818abac_stack_t *abac_pl_query(abac_pl_t *pl, char *role, char *principal); 
     19abac_stack_t *abac_pl_query_with_structure(abac_pl_t *pl, abac_aspect_t *head_aspect, abac_aspect_t *tail_aspect); 
    1920 
    2021/* return a list of all credentials in the pl file */ 
  • libabac/rt2.y

    r5110d42 rd9c3886  
    151151                 } else { 
    152152                     if((USE("ABAC_CN")) && cn==NULL) { 
    153                          asprintf(&tmp,"encountered an invalid SHA id(%s)",$5); 
     153                         if(debug) 
     154                             asprintf(&tmp,"encountered an invalid SHA id(%s)",$5); 
     155                         else asprintf(&tmp,"encountered an invalid SHA id"); 
    154156                         panic(tmp); 
    155157                         free(tmp); 
Note: See TracChangeset for help on using the changeset viewer.