Changeset d9c3886
- Timestamp:
- 05/18/12 00:58:12 (13 months ago)
- 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)
- Files:
-
- 16 edited
-
examples/creddy_prover_tests/allout.save (modified) (2 diffs)
-
examples/creddy_prover_tests/runall (modified) (3 diffs)
-
examples/creddy_prover_tests/runcheck (modified) (1 diff)
-
examples/python_tests/allout.save (modified) (1 diff)
-
examples/python_tests/basic_id/README (modified) (1 diff)
-
examples/python_tests/basic_id/id.py (modified) (1 diff)
-
examples/python_tests/basic_id/id.save (modified) (3 diffs)
-
examples/python_tests/basic_id/run_test (modified) (1 diff)
-
examples/python_tests/runall (modified) (2 diffs)
-
examples/python_tests/runcheck (modified) (1 diff)
-
libabac/abac.c (modified) (1 diff)
-
libabac/abac.h (modified) (1 diff)
-
libabac/abac.hh (modified) (6 diffs)
-
libabac/abac_pl_yap.c (modified) (1 diff)
-
libabac/abac_pl_yap.h (modified) (1 diff)
-
libabac/rt2.y (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
examples/creddy_prover_tests/allout.save
r5110d42 rd9c3886 46 46 47 47 ===bad============ Acme.preferred_customer <- badCoyote 48 yyerror: encountered an invalid SHA id (bad)48 yyerror: encountered an invalid SHA id 49 49 prover failed!! 50 50 … … 64 64 65 65 ===bad============ 99Acme.buy_rockets <- Coyote 66 yyerror: encountered an invalid SHA id (994956018dbb522c97da1e0f19d7713510b14eb712)66 yyerror: encountered an invalid SHA id 67 67 prover failed!! 68 68 -
examples/creddy_prover_tests/runall
r5110d42 rd9c3886 7 7 8 8 progname=$(basename $0) 9 pwd=`pwd` 9 10 10 11 if [ $# -eq 0 ]; then … … 17 18 18 19 for i in `ls -1 `; do 19 if ( file $i | grep -Fq directory ); then20 cd $i ;20 if [ -d $i ]; then 21 cd $i 21 22 if [ "$1" = "clean" ]; then 22 23 rm -rf ../allout.sha ../allout.cn … … 30 31 ./run_query 31 32 fi 32 cd ..;33 cd $pwd 33 34 fi 34 35 done -
examples/creddy_prover_tests/runcheck
r5110d42 rd9c3886 6 6 export ABAC_PROVER_PATH 7 7 8 echo 'running ABACtesting...'8 echo 'running libabac CREDDY/ABAC_PROVER_YAP testing...' 9 9 echo ' ---with sha' 10 10 env ./runall run 1> allout.sha 2>/dev/null -
examples/python_tests/allout.save
r5110d42 rd9c3886 1 1 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 10 12 ---run with sha 11 13 ---run with cn -
examples/python_tests/basic_id/README
r5110d42 rd9c3886 6 6 # In yap db, the ID credential is stored as: isType(pIDname,keyid) 7 7 8 # Two pre-existing id credentials are generated using creddy, this is9 # to test the load_directory api call10 creddy --generate --cn CreddyBob11 creddy --generate --cn CreddyJack12 8 13 9 # -
examples/python_tests/basic_id/id.py
r5110d42 rd9c3886 43 43 id=ABAC.ID("John", 0) 44 44 print "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")45 id.write_privkey("John_other.pem") 46 id.write_cert("John_other.pem") 47 ctxt.load_id_file("John_other.pem") 48 48 49 49 id=ABAC.ID("Lori", 0) -
examples/python_tests/basic_id/id.save
r5110d42 rd9c3886 3 3 ABAC version 1.0 4 4 ...initial principal set... 5 (p CreddyBob,keyid,y)6 (p CreddyJack,keyid,y)5 (pBob,keyid,y) 6 (pJack,keyid,y) 7 7 (pMary,keyid,y) 8 8 (pLori,keyid,n) … … 18 18 adding -> Casper(bad,unknown file) 19 19 ...final principal set... 20 (p CreddyBob,keyid,y)21 (p CreddyJack,keyid,y)20 (pBob,keyid,y) 21 (pJack,keyid,y) 22 22 (pMary,keyid,y) 23 23 (pLori,keyid,n) … … 30 30 31 31 ========= yap db (dump_yap) 32 isType(p CreddyBob,keyid).33 isType(p CreddyJack,keyid).32 isType(pBob,keyid). 33 isType(pJack,keyid). 34 34 isType(pMary,keyid). 35 35 isType(pLori,keyid). -
examples/python_tests/basic_id/run_test
r5110d42 rd9c3886 8 8 9 9 echo '---setup principals' 10 ./ README10 ./setup.py 2>/dev/null 1 > id.sha 11 11 12 12 echo '---run with sha' -
examples/python_tests/runall
r5110d42 rd9c3886 6 6 7 7 progname=$(basename $0) 8 pwd=`pwd` 8 9 9 10 if [ $# -eq 0 ]; then 10 echo "Usage: $progname (clean| setup|run)" >&2;11 echo "Usage: $progname (clean|run)" >&2; 11 12 exit 1 12 13 fi … … 16 17 17 18 for i in `ls -1 `; do 18 if ( file $i | grep -Fq directory ); then19 cd $i ;19 if [ -d $i ]; then 20 cd $i 20 21 if [ "$1" = "clean" ]; then 21 22 rm -rf ../allout.tmp 22 23 printf "\n ==> CLEANING on %s\n" "$i" >& 2 ; 23 24 rm -rf *.der *.pem *.cn *.sha 24 elif [ "$1" = "setup" ]; then25 printf "\n ==> SETUP on %s\n" "$i" >& 2;26 ./README27 25 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 32 28 fi 33 cd ..;29 cd $pwd 34 30 fi 35 31 done -
examples/python_tests/runcheck
r5110d42 rd9c3886 6 6 export ABAC_PROVER_PATH 7 7 8 echo 'running PYTHON testing...'8 echo 'running libabac PYTHON testing...' 9 9 10 10 env ./runall run 1> allout.tmp 2>& 1 -
libabac/abac.c
r5110d42 rd9c3886 297 297 } 298 298 299 abac_credential_t **abac_context_query_with_structure(abac_context_t *ctx, 300 abac_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 299 339 /** 300 340 * A NULL-terminated array of all the credentials in the context. -
libabac/abac.h
r5110d42 rd9c3886 43 43 /* abac query, returns a NULL-terminated array of credentials on success, NULL on fail */ 44 44 abac_credential_t **abac_context_query(abac_context_t *ctx, char *role, char *principal, int *success); 45 abac_credential_t **abac_context_query_with_structure(abac_context_t *, abac_aspect_t*, abac_aspect_t*, int*); 45 46 46 47 /* get all the credentials from the context, returns a NULL-terminated array of credentials */ -
libabac/abac.hh
r5110d42 rd9c3886 15 15 class Oset; 16 16 17 /*** 18 ABAC::Constraint 19 This is a constraint on a data term. It holds a ptr to 20 a abac_condition_t structure 21 ***/ 17 22 class Constraint { 18 23 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 ***/ 20 53 Constraint(abac_condition_t *constraint): 21 54 m_constraint(abac_condition_dup(constraint)) 22 55 { } 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 30 56 /* range constraint */ 31 57 Constraint(char *vartype) { m_constraint=abac_condition_create(vartype); } 32 58 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 ***/ 35 68 void add_constraint_integer_max(int val) { 36 69 abac_condition_add_range_integer_item(m_constraint,abac_max_item_type(),val); … … 42 75 abac_condition_add_range_integer_item(m_constraint,abac_target_item_type(),val); 43 76 } 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 ***/ 44 86 void add_constraint_float_max(float val) { 45 87 abac_condition_add_range_float_item(m_constraint,abac_max_item_type(),val); … … 683 725 int i, success_int; 684 726 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); 695 728 success = success_int; 696 729 … … 702 735 703 736 abac_context_credentials_free(creds); 704 free(role_str);705 free(p_role_str);706 737 707 738 return attributes; … … 711 742 abac_credential_t **creds, **end; 712 743 int i, success_int; 713 /* make sure retrieving SHA not CN embedded string */714 744 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); 721 746 success = success_int; 722 747 … … 729 754 730 755 abac_context_credentials_free(creds); 731 free(oset_str);732 free(p_oset_str);733 756 734 757 return attributes; -
libabac/abac_pl_yap.c
r5110d42 rd9c3886 384 384 } 385 385 386 abac_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 386 394 void abac_pl_free(abac_pl_t *pl) { 387 395 if(pl->fptr) { -
libabac/abac_pl_yap.h
r5110d42 rd9c3886 17 17 /* return a list of credentials */ 18 18 abac_stack_t *abac_pl_query(abac_pl_t *pl, char *role, char *principal); 19 abac_stack_t *abac_pl_query_with_structure(abac_pl_t *pl, abac_aspect_t *head_aspect, abac_aspect_t *tail_aspect); 19 20 20 21 /* return a list of all credentials in the pl file */ -
libabac/rt2.y
r5110d42 rd9c3886 151 151 } else { 152 152 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"); 154 156 panic(tmp); 155 157 free(tmp);
Note: See TracChangeset
for help on using the changeset viewer.
