Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
P
parlote-facil
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
facil
parlote-facil
Validations
93e900b9
Valider
93e900b9
rédigé
il y a 14 ans
par
Raphael
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
fixed comments, did I break request url?
parent
8d00063b
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
4
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
4 fichiers modifiés
app/models/comment.rb
+1
-0
1 ajout, 0 suppression
app/models/comment.rb
app/models/user.rb
+0
-1
0 ajout, 1 suppression
app/models/user.rb
lib/encryptable.rb
+9
-5
9 ajouts, 5 suppressions
lib/encryptable.rb
spec/user_encryption_spec.rb
+16
-18
16 ajouts, 18 suppressions
spec/user_encryption_spec.rb
avec
26 ajouts
et
24 suppressions
app/models/comment.rb
+
1
−
0
Voir le fichier @
93e900b9
...
...
@@ -52,6 +52,7 @@ class Comment
def
verify_post_creator_signature
unless
person
==
User
.
owner
puts
"verifying post creator sig from
#{
post
.
person
.
real_name
}
"
verify_signature
(
post_creator_signature
,
post
.
person
)
else
true
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
app/models/user.rb
+
0
−
1
Voir le fichier @
93e900b9
...
...
@@ -56,7 +56,6 @@ class User < Person
end
def
receive_friend_request
(
friend_request
)
puts
friend_request
.
inspect
Rails
.
logger
.
info
(
"receiving friend request
#{
friend_request
.
to_json
}
"
)
GPGME
.
import
(
friend_request
.
exported_key
)
if
Request
.
where
(
:callback_url
=>
friend_request
.
callback_url
).
first
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
lib/encryptable.rb
+
9
−
5
Voir le fichier @
93e900b9
...
...
@@ -9,10 +9,10 @@
def
verify_signature
(
signature
,
person
)
return
false
unless
signature
&&
person
.
key_fingerprint
validity
=
nil
GPGME
::
verify
(
creator_
signature
,
signable_string
,
{
:armor
=>
true
,
:always_trust
=>
true
}){
|
sig
nature
|
validity
=
sig
nature
.
status
==
GPGME
::
GPG_ERR_NO_ERROR
&&
sig
nature
.
fpr
==
person
.
key_fingerprint
GPGME
::
verify
(
signature
,
signable_string
,
{
:armor
=>
true
,
:always_trust
=>
true
}){
|
sig
|
validity
=
sig
.
status
==
GPGME
::
GPG_ERR_NO_ERROR
&&
sig
.
fpr
==
person
.
key_fingerprint
}
return
validity
end
...
...
@@ -25,8 +25,12 @@
end
def
sign
sign_with_key
(
User
.
owner
.
key
)
end
def
sign_with_key
(
key
)
GPGME
::
sign
(
signable_string
,
nil
,
{
:armor
=>
true
,
:mode
=>
GPGME
::
SIG_MODE_DETACH
,
:signers
=>
[
User
.
owner
.
key
]})
{
:armor
=>
true
,
:mode
=>
GPGME
::
SIG_MODE_DETACH
,
:signers
=>
[
key
]})
end
end
Ce diff est replié.
Cliquez pour l'agrandir.
spec/user_encryption_spec.rb
+
16
−
18
Voir le fichier @
93e900b9
...
...
@@ -100,8 +100,7 @@ describe 'user encryption' do
it
'should verify a remote signature'
do
message
=
Factory
.
build
(
:status_message
,
:person
=>
@person
)
message
.
creator_signature
=
GPGME
.
sign
(
message
.
signable_string
,
nil
,
{
:mode
=>
GPGME
::
SIG_MODE_DETACH
,
:armor
=>
true
,
:signers
=>
[
@person
.
key
]})
message
.
creator_signature
=
message
.
send
(
:sign_with_key
,
@person
.
key
)
message
.
save
(
:validate
=>
false
)
message
.
verify_creator_signature
.
should
be
true
end
...
...
@@ -109,16 +108,14 @@ describe 'user encryption' do
it
'should know if the signature is from the wrong person'
do
message
=
Factory
.
build
(
:status_message
,
:person
=>
@person
)
message
.
save
(
:validate
=>
false
)
message
.
creator_signature
=
GPGME
.
sign
(
message
.
signable_string
,
nil
,
{
:mode
=>
GPGME
::
SIG_MODE_DETACH
,
:armor
=>
true
,
:signers
=>
[
@person
.
key
]})
message
.
creator_signature
=
message
.
send
(
:sign_with_key
,
@person
.
key
)
message
.
person
=
@user
message
.
verify_creator_signature
.
should
be
false
end
it
'should know if the signature is for the wrong text'
do
message
=
Factory
.
build
(
:status_message
,
:person
=>
@person
)
message
.
creator_signature
=
GPGME
.
sign
(
message
.
signable_string
,
nil
,
{
:mode
=>
GPGME
::
SIG_MODE_DETACH
,
:armor
=>
true
,
:signers
=>
[
@person
.
key
]})
message
.
creator_signature
=
message
.
send
(
:sign_with_key
,
@person
.
key
)
message
.
message
=
'I love VENISON'
message
.
save
(
:validate
=>
false
)
message
.
verify_creator_signature
.
should
be
false
...
...
@@ -133,8 +130,7 @@ describe 'user encryption' do
end
it
'A message with an invalid signature should be rejected'
do
message
=
Factory
.
build
(
:status_message
,
:person
=>
@person
)
message
.
creator_signature
=
GPGME
.
sign
(
message
.
signable_string
,
nil
,
{
:mode
=>
GPGME
::
SIG_MODE_DETACH
,
:armor
=>
true
,
:signers
=>
[
@user
.
key
]})
message
.
creator_signature
=
message
.
send
(
:sign
)
message
.
save
xml
=
Post
.
build_xml_for
([
message
])
message
.
destroy
...
...
@@ -147,10 +143,9 @@ describe 'user encryption' do
describe
'comments'
do
before
do
@remote_message
=
Factory
.
build
(
:status_message
,
:person
=>
@person
)
@remote_message
.
creator_signature
=
GPGME
.
sign
(
@remote_message
.
signable_string
,
nil
,
{
:mode
=>
GPGME
::
SIG_MODE_DETACH
,
:armor
=>
true
,
:signers
=>
[
@person
.
key
]})
@remote_message
.
creator_signature
=
@remote_message
.
send
(
:sign_with_key
,
@person
.
key
)
@remote_message
.
save
@message
=
Factory
.
create
(
:status_message
,
:person
=>
@user
)
end
it
'should attach the creator signature if the user is commenting'
do
@user
.
comment
"Yeah, it was great"
,
:on
=>
@remote_message
...
...
@@ -160,29 +155,32 @@ describe 'user encryption' do
it
'should sign the comment if the user is the post creator'
do
message
=
Factory
.
create
(
:status_message
,
:person
=>
@user
)
@user
.
comment
"Yeah, it was great"
,
:on
=>
message
StatusMessage
.
first
.
comments
.
first
.
verify_creator_signature
.
should
be
true
message
.
comments
.
first
.
verify_creator_signature
.
should
be
true
StatusMessage
.
first
.
comments
.
first
.
verify_post_creator_signature
.
should
be
true
end
it
'should verify a comment made on a remote post by a different friend'
do
comment
=
Comment
.
new
(
:person
=>
@person2
,
:text
=>
"balls"
,
:post
=>
@remote_message
)
comment
.
creator_signature
=
GPGME
.
sign
(
comment
.
signable_string
,
nil
,
{
:mode
=>
GPGME
::
SIG_MODE_DETACH
,
:armor
=>
true
,
:signers
=>
[
@person2
.
key
]})
comment
.
creator_signature
=
comment
.
send
(
:sign_with_key
,
@person2
.
key
)
comment
.
verify_creator_signature
.
should
be
true
comment
.
valid?
.
should
be
false
comment
.
post_creator_signature
=
comment
.
send
(
:sign_with_key
,
@person
.
key
)
comment
.
verify_post_creator_signature
.
should
be
true
comment
.
valid?
.
should
be
true
end
it
'should reject comments on a remote post with only a creator sig'
do
comment
=
Comment
.
new
(
:person
=>
@person2
,
:text
=>
"balls"
,
:post
=>
@remote_message
)
comment
.
creator_signature
=
GPGME
.
sign
(
comment
.
signable_string
,
nil
,
{
:mode
=>
GPGME
::
SIG_MODE_DETACH
,
:armor
=>
true
,
:signers
=>
[
@person2
.
key
]})
comment
.
creator_signature
=
comment
.
send
(
:sign_with_key
,
@person2
.
key
)
comment
.
verify_creator_signature
.
should
be
true
comment
.
verify_post_creator_signature
.
should
be
false
comment
.
save
.
should
be
false
end
it
'should receive remote comments on a user post with a creator sig'
do
comment
=
Comment
.
new
(
:person
=>
@person2
,
:text
=>
"balls"
,
:post
=>
@message
)
comment
.
creator_signature
=
comment
.
send
(
:sign_with_key
,
@person2
.
key
)
comment
.
save
.
should
be
true
end
end
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter